Check mail sent with mail command

0

I've got a Debian mail server, and I use the mail command to send confirmation e-mails when users register our website. Is there any way to view a list of the mails that were sent?

Any help much appreciated!

Flock Dawson

Posted 2013-10-15T09:09:45.280

Reputation: 281

Answers

0

You're doing it wrong. Add a Bcc ("blind carbon copy") header to all your generated mails containing a special technical address, say, generated-mails, then add an entry for it to the system aliases table, like this:

generated-mails: "| /usr/local/bin/process-generated-message"

where the /usr/local/bin/process-generated-message should be an executable program which expects the message on its standard input and does with it whatever it wants.

Alternatively, you can just append these messages to a file:

generated-mails: /var/local/spool/generated-mails

(Note that this file must be writable by the user (and/or group) which postfix on your system uses when it's delivering mails locally — this is OS-dependent.)

The details are explained here.

I recommend using Bcc header field (and not Cc) as it gets stripped off from the message when it's being sent do the actual recipients, so they don't see this cruft in their messages.

kostix

Posted 2013-10-15T09:09:45.280

Reputation: 2 435

Thank you for your reply! The problem was that I needed to retrieve a log from mails sent in the past (before a measure like the one you described above was taken). I'll be adding this feature in the future though. – Flock Dawson – 2013-10-16T08:17:18.037

0

After some digging, I found out there are some records in the /var/logs/syslog files So I used grep to sort them out:

cat syslog | grep "localhost postfix/smtp\["

Flock Dawson

Posted 2013-10-15T09:09:45.280

Reputation: 281