49

I used mailq command and I got a line like for example:

A705238B4C   603953 Wed May 23 11:09:58  [email protected]

So, now I'm wondering is there a way where I can "read" an actual content of the mail by its id A705238B4C

2 Answers 2

80

The best way is to make use of the postcat command.

postcat -q A705238B4C

At least the system I can look at right now, /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 (A705238B4C) or with some level of hashing depth (A/7/05238B4C).

2
  • 1
    If you do dig down into these directories rather than using postcat, the files are part binary but mostly text so strings or hexdump are the best utilities for reading them depending on which bits you want to see.
    – Ladadadada
    May 23, 2012 at 22:21
  • 1
    postfix queue files are RFC822 messages. There is no binary data other than in the queue headers used internally by postfix (nexthop data, queue delay etc.)
    – adaptr
    May 24, 2012 at 9:50
2

As stated in Jeff's answer you can use postcat with the -q option.

But 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=DEDCB58048B
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .