LinuxCommandLibrary

mailq

Show emails queued for delivery

SYNOPSIS

mailq [-v]

The command is often a symbolic link to an MTA-specific command (e.g., sendmail -bp or postfix -p), and therefore, its actual options may be inherited from the underlying MTA. The -v option is commonly supported for verbose output.

PARAMETERS

-v
    Displays the mail queue in a verbose format, often providing more details about each message, such as full sender/recipient addresses, error messages, and headers.

DESCRIPTION

mailq is a command-line utility used to display the contents of the mail queue on a Linux or Unix-like system. It shows messages that are waiting to be processed, delivered, or have been temporarily deferred due to various reasons (e.g., recipient server unavailable, network issues, large queue backlog).

The output typically includes the unique queue ID for each message, its size, the time it entered the queue, the sender's address, the intended recipients, and its current status.

System administrators frequently use mailq to monitor the mail system's health, identify and troubleshoot mail delivery problems, and assess the load on the mail server. On most systems, mailq is a symbolic link or wrapper for the underlying Mail Transfer Agent (MTA) command, such as sendmail -bp for Sendmail, or postfix -p for Postfix. This means its exact behavior and available options can vary slightly depending on the MTA in use.

CAVEATS

mailq is frequently an alias or wrapper script for the system's underlying Mail Transfer Agent (MTA), such as Postfix, Sendmail, or Exim. Consequently, its exact behavior, available options, and output format can differ significantly between systems based on the installed MTA.

Access to the mail queue usually requires administrative privileges (e.g., root access or membership in a specific mail-related group) to prevent unauthorized viewing of sensitive email information.

For very large mail queues, the output of mailq can be extensive and may take time to process, potentially consuming system resources.

COMMON OUTPUT FIELDS

When running mailq, you'll typically see columns providing key information about each message in the queue:

Queue ID: A unique identifier for the message.
Size: The size of the message in bytes.
Arrival Time: The date and time the message entered the queue.
Sender: The envelope sender address.
Recipients: One or more intended recipient addresses. For deferred messages, an error message or reason for deferral might also be shown.

ADMINISTRATIVE USE CASES

mailq is a crucial tool for system administrators to:

1. Monitor Mail Flow: Quickly see the volume of mail being processed.
2. Troubleshoot Delivery Issues: Identify messages that are stuck or deferred, often with accompanying error messages.
3. Assess System Load: A rapidly growing queue might indicate performance problems or spam attacks.
4. Verify Mail Operations: Confirm that messages are being processed and moved out of the queue as expected.

HISTORY

The concept of listing the mail queue originated with the early development of Unix mail systems, prominently with Sendmail. The command sendmail -bp was the standard method to display the contents of the print (P) queue. Over time, mailq emerged as a convenient, user-friendly alias or wrapper command for this functionality.

As new Mail Transfer Agents like Postfix and Exim gained popularity, they adopted the mailq command, often implementing it as a symbolic link (e.g., to postfix -p) or a simple script to maintain a consistent interface for queue inspection across different MTA environments. This has made mailq a widely recognized and indispensable tool for mail system administration on Linux and Unix-like operating systems.

SEE ALSO

sendmail(8), postfix(1), postsuper(1), exim(8), mail(1), newaliases(1), mailstat(1)

Copied to clipboard