Prevent sendmail from sending emails and instead save them to a file

sendmail

I want to test a Newsletter application on a dummy server but I don't want all the clients in my DB (dumped from the live server) to get an email. Is there any way to prevent sendmail from sending those mails really out and instead save them to a file or something similar?

Best Answer

You can do something like this:

LOCAL_CONFIG
# File that contains recipients usernames that interest us in this test
F{Users} -o /etc/mail/users-to-test
# File that contains recipients domains that interest us in this test
F{Domains} -o /etc/mail/domains-to-test

LOCAL_RULE_2
R $={Users} < @ $={Domains} . >      $#discard $: discard

/etc/mail/users-to-test contains the usernames that we do not want them to receive email from the test server. This addition to Ruleset 2 discards all email directed to them, and it is assumed that the above ruleset is applied to the sendmail running in your test machine and not on the production server.

PS: tabs separate the left from the right hand side of the rules. tabs and not spaces, so do not copy-paste.