Postfix - How to write outgoing mail to harddrive (not internet)?

Yes it is possible. Add the following lines to your /etc/postfix/master.cf:

fs_mail    unix  -       n       n       -       -       pipe
   flags=F user=%YOUR_USER_NAME% argv=tee /home/%YOUR_USER_NAME%/fs_mail.dump

And then add this line to your /etc/postfix/main.cf:

default_transport = fs_mail

And then restart your Postfix server

sudo /etc/init.d/postfix restart

And it should save all outgoing mail into fs_mail.dump file in your home folder (replace %YOUR_USER_NAME% with your real username ;) )


You can use the smtp-sink utility that ships with postfix:

smtp-sink -u root -d %d.%H.%M.%S 192.168.1.10:25 10

smtp-sink writes out the files with a timestamp.hex

Cheers

P.S.

You were pretty quick on the acceptance of the best answer.

P.P.S.

You specifically mentioned postfix so I mentioned smtp-sink but fakemail works better IMHO as it writes out the files as [email protected] where N is the occurrence of the same address. http://sourceforge.net/projects/fakemail/


one way is redirect all mails to a local account.

# main.cf

header_checks = regexp:/etc/postfix/header_checks

# /etc/postfix/header_checks

/./   REDIRECT [email protected]