View the Sendmail or Postfix mail queue

Author: Cezary Morga cm@therek.net FreeBSD

Reviewer: name contact BSD flavour

Reviewer: name contact BSD flavour


Concept

Be able to view the mail queue to determine if any mail is stuck in the queue, and if necessary, ask the MTA to reprocess or flush the queue.

Introduction

As noted in section Determine which MTA is being used on the system, the BSD systems use Sendmail or Postfix by default for handling mail.

The mail queue can be displayed using the mailq(1) utility. The queue listing identifies messages that are still queued (not successfully sent or delivered yet). The output includes MTA's internal message identifier, the size of the message, the date and time the message was accepted into the queue, the sender's envelope address, and the recipient address(es), as well as a reason of failure for messages that have permanently failed.

When using Postfix, if the mailq(1) utility is not setup, use postqueue -p to display the traditional sendmail-style queue listing. To make MTA attempt to deliver all queued mail issue commands: sendmail -q for Sendmail and postqueue -f for Posftix.

Examples

Following are two examples of mailq(1) output. First when used with Sendmail:

""# mailq ""/var/spool/mqueue (1 request) ""-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient----------- ""l0ID36a2085983 524 Thu Jan 18 14:03 <sender@mydomain.net> "" (Deferred: Operation timed out with otherdomain.com.) "" <recipient@otherdomain.com> "" Total requests: 1

And an example when used with Postfix:

""# mailq ""-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient------- ""D184ACAB55 709 Fri Jan 19 20:50:08 sender@mydomain.net ""(delivery temporarily suspended: connect to mail.otherdomain.com[10.0.0.11]: Connection refused) "" recipient@otherdomain.com "" ""-- 709 bytes in 1 Request.

Practice Exercises

  1. When logged into your mail server, see the output of postqueue(1) and/or mailq(1) commands (depending on which MTA is used).

More information

mailq(1), postqueue(1)