mailq Command Examples in Linux

The mailq command lists any outgoing email messages awaiting delivery:

# mailq
Queue ID- --Size-- ----Arrival Time--  -Sender/Recipient--
46AAB43972*    333 Tue Jan 10 21:17:14 smith@example.com
                                       jones@elsewhere.org

Sent mail messages are also recorded in a log file, /var/log/mail.log.

mailq Command Examples

1. To see the mails in queue:

# mailq 

2. To show the mail submission queue specified:

# mailq -Ac 

3. To show the “lost” items in the mail queue instead of the normal queue items:

# mailq -qL 

4. To show the quarantined items in the mail queue instead of the normal queue items:

# mailq -qQ 

5. To Limit processed jobs to those containing substr as a substring:

# mailq -q[!]I substr 

6. To Limit processed jobs to quarantined jobs containing substr as a substring:

# mailq -q[!]Q substr 

7. To Limit processed jobs to those containing substr as a substring of one of the recipients:

# mailq -q[!]R substr 

8. To limit processed jobs to those containing substr as a substring:

# mailq -q[!]S substr 

9. To Print verbose information:

# mailq -v 

Note

Sendmail is an intelligent mail agent, and it tries to deliver mail even when failures occur. For example, if a user attempts to send an email to user@hostname.com, and the mail server for hostname.com is turned off, sendmail will be unable to make a connection to TCP port 25 on the mail server for hostname.com and consequently won’t be able to deliver the mail. Instead of giving up, sendmail will place the email in a queue and attempt redelivery. The default action of sendmail is to attempt redelivery of queued mail every 4 hours for 5 days before giving up and sending a “Delivery Failure” notification to the original sender. Queued mail is stored in the directory /var/spool/mqueue and is managed by the program mailq.

Related Post