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!


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.

  • 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 Oct 16 '13 at 8:17

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\["

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.