The Wayback Machine - https://web.archive.org/web/20250114221752/https://www.geeksforgeeks.org/mailq-command-in-linux-with-examples/
Open In App

mailq Command in Linux with Examples

Last Updated : 22 Oct, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

mailq i.e. “mail-queue”, this command in Linux prints the mail queue i.e. the list of messages that are there in the mail queue. You should have a mail-server setup on your Linux machine, to use this command, there are ways i.e MTA’s(Mail Transfer agent) you can use like sendmail which uses the service smtp. The output of mailq command is similar to the sendmail -bp command that also prints the mail queue.

Syntax

mailq [options]

The most commonly used options include -v for verbose mode, which provides more detailed information such as message priority.

Practical Examples of the mailq Command

Example 1: maliq without any option

Simply prints the messages in the mail queue.

$ mailq

Output

 Mail Queue (1 request)
---QID---- --Size-- -----Q-Time----- ------Sender/Recipient-----
SS04506 5 Tue Nov 12 09:01 root
(User unknown)

Example 2: Prints along with priority specified

Simply prints the messages in the mail queue.

$ mailq -v

Output

 Mail Queue (1 request)
---QID---- --Size-- -Priority- -----Q-Time----- ------Sender/Recipient-----
SS04506 5 2005 Tue Nov 12 09:01 root
(User unknown)

Here,

  • QID: Specific ID allotted to message.
  • Size: Number of bytes contained in body of message.
  • Q-Time Time at which message entered the queue.

Real-World Applications of mailq

  • Managing High Email Traffic: mailq helps administrators monitor email queues, ensuring efficient processing during high-volume campaigns.
  • Troubleshooting Failed Emails: It identifies failed messages due to issues like incorrect addresses or full mailboxes, enabling quick fixes.
  • Prioritizing Critical Emails: mailq allows adjusting the flow of high-priority messages, such as transactional emails or alerts.
  • Tracking Delivery Delays: mailq provides insights into delayed emails, helping with diagnostics and load balancing.

Conclusion

The mailq command is an essential tool for managing email queues in Linux-based systems. It allows system administrators to view the status of emails waiting in the queue, troubleshoot delivery issues, and optimize the flow of outgoing messages. In environments with high email traffic, mailq plays a critical role in maintaining the efficiency and reliability of mail servers.

mailq Command in Linux – FAQs

What is the difference between mailq and sendmail -bp?

Both commands display the mail queue, but mailq is simpler and more intuitive to use. sendmail -bp is the Sendmail command for printing the mail queue, and it provides similar output.

What does the -v option in mailq do?

The -v option runs the mailq command in verbose mode, displaying additional details such as the priority of queued messages.

How do I clear the mail queue?

To clear the mail queue, you can use commands specific to your MTA (e.g., Postfix or Sendmail). For example, in Postfix, you can use postsuper -d ALL to delete all queued messages.

Can mailq be used to view outgoing emails only?

Yes, mailq primarily shows the queue of outgoing emails. It lists messages that are waiting to be delivered from the server to their intended recipients.

Master DevOps and also get 90% Course fee refund on completing 90% course in 90 days! Take the Three 90 Challenge today.

The most sought-after Three 90 challenge has started and this is your chance to upskill and get 90% refund. What more motivation do you need? Start the challenge right away!


Next Article

Similar Reads

three90RightbarBannerImg