The mailq Command in Linux

Find out what's still queued for delivery

Penguin Using a Laptop Computer
John Coulter / Getty Images

Mailq prints a summary of the email messages queued for future delivery in a Linux operating system. It functions identically to the command sendmail -bp.

The first line printed for each message shows the internal identifier used on your specific host for the message, with a possible status character, the size of the message in bytes, the date and time the message was accepted into the queue, and the envelope sender of the message.

The second line shows the error message that caused this message to be retained in the queue; it will not be present if the message is being processed for the first time. The status characters are either an asterisk to indicate the job is being processed, an X to indicate that the load is too high to process the job, or a hyphen to indicate that the job is too young to process.

The following lines of output show the message recipients, one per line.

Depending on your distribution, you may not have mailq or sendmail installed by default. In particular, desktop Linux distributions that don't send mail natively from within the operating system are unlikely to use either command. There's no value to installing mailq or sendmail if your local machine doesn't send messages.

mailq Command Syntax

mailq -v command

The command takes the following form:

mailq [-Ac] [-q...] [-v]  

The command accepts the following switches:

mailq Executing mailq without any switches shows the queued emails.
-Ac Show the mail submission queue specified in /etc/mail/submit.cf instead of the MTA queue specified in /etc/mail/sendmail.cf.
-q[!]I substr Limit processed jobs to those containing substr as a substring of the queue id or not when !is specified.
-q[!]R substr Limit processed jobs to those containing substr as a substring of one of the recipients or not when ! is specified.
-q[!]S substr Limit processed jobs to those containing substr as a substring of the sender or not when ! is specified.
-v Print verbose information. This switch adds the priority of the message and a single character indicator (a plus sign or a blank space) indicating whether a warning message has been sent on the first line of the message.1

'mailq' Example

This is an example of what the mailq command might look like after being executed:

     Mail Queue (1 request)
---QID---- --Size-- -----Q-Time----- ------Sender/Recipient------
AA45401        5    Thu Mar 10 11:15 root (User unknown) bad_user