How can I see the contents of the mail whose ID I get from mailq command?
You can see the contents of the mail whose ID you get from the mailq
command by using the postcat
command. Here’s how you can do it:
postcat -q YOUR_MAIL_ID
Replace YOUR_MAIL_ID
with the ID of the mail you got from the mailq
command.
The system directory /var/spool/postfix
is the master directory. Subdirectories of that which matter include active
, deferred
, bounce
, etc. Queued files may be stored using the full file name (like A705238B4C) or with some level of hashing depth (like A/7/05238B4C)
Since Postfix version 2.7, you can also get readable output, by adding the -h
and/or -b
options:
b
: Show body content.h
: Show message header content.q
: Search the Postfix queue for the named files instead of taking the names literally.
So this will show you the entire original message with headers and body:
id=YOUR_MAIL_ID
postcat -bh -q $id
Or to show the headers of all queued messages, you could do something like this:
mailq | awk '/^ [A-F0-9]+\\s+/ {print $1}' \\ | while read id; do echo $id; postcat -h -q $id; echo; done
Again, replace [YOUR_MAIL_ID](https://serverfault.com/questions/391995/how-can-i-see-the-contents-of-the-mail-whose-id-i-get-from-mailq-command)
with the ID of the mail you got from the [mailq](https://serverfault.com/questions/391995/how-can-i-see-the-contents-of-the-mail-whose-id-i-get-from-mailq-command)
command.
-
Is Postfix the same thing as Sendmail?
No, Postfix and Sendmail are not the same thing, although they serve a similar purpose. Both are Mail Transfer Agents (MTAs), which are responsible for routing and delivering email messages between...
Questions -
How do I check the postfix queue size?
You can check the size and status of the Postfix mail queue using the postqueue command. To view the size of the queue, follow these steps: Open a terminal or SSH session to your server. Use the po...
Questions -
How to automate the installation of postfix on Ubuntu?
Automating the installation of Postfix on Ubuntu can be done using a package management tool like apt and a script or a configuration management tool like Ansible. Below are two methods to automate...
Questions -
How to correct Postfix' 'Relay Access Denied'?
The "Relay Access Denied" error in Postfix typically occurs when Postfix receives an email from an external sender and determines that it should not relay the email to its destination. This error m...
Questions
Make your mark
Join the writer's program
Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.
Write for usBuild on top of Better Stack
Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.
community@betterstack.comor submit a pull request and help us build better products for everyone.
See the full list of amazing projects on github