JEROME
JEROME

Reputation: 149

How to get or catch email bodies and headers sent by postfix

I need catch email bodies and headers that are sent by postfix on my Ubuntu server.

Could you please explain me, how to catch it?

I know I can do it by postcat (postcat -vq XXXXXXXXXX) when message is in mail queue, but unfortunately I don't know queue ID (XXXXXXXXXX) and when I find it, message is already sent.

Upvotes: 4

Views: 8463

Answers (2)

trogper
trogper

Reputation: 1693

if you want to pause delivery of mail to other servers, you could defer smtp transport, do the deed and then undefer it. You will stil get mail delivered to you from other servers.

sudo postconf -e defer_transports=smtp; sudo postfix reload
echo "test message" | mail -s "test" [email protected]
mailq
postcat -vq C23D82B60024
sudo postconf -e defer_transports=; sudo postfix reload; sudo postfix flush

source: nixtips.net

Upvotes: 2

JEROME
JEROME

Reputation: 149

  1. send email
  2. stop postfix
  3. get queue ID
  4. postcat -vq ID

for example:

echo "test message" | mail -s "test" [email protected]
service postfix stop
mailq
postcat -vq C23D82B60024

Upvotes: 8

Related Questions