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?
3 Answers
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.

- 6,925
- 3
- 30
- 58
We do this using multiple sendmail instances (each listening on different virtual interface) on a dedicated SMTP server which also runs cyrus IMAP server. We have multiple instances because we'll have multiple sets of developers/testers trying out different things.
In the sendmail mc file ...
FEATURE(`mailertable', `hash -o /etc/mail/mroute2-mailertable.db')dnl
In the mailertable file (fields separated by tabs, order of lines important) ...
mailtest.ncl.ac.uk smtp:mailtest.ncl.ac.uk
. local:paul
That example has messages for users at the mailtest.ncl.ac.uk domain being delivered normally with everything else delivered to paul's local mailbox. If you want all messages to be stored in a local mailbox then just a single line of the form
. local:paul
should do it.

- 4,517
- 1
- 21
- 32
If you have a Windows box around there is a simple single .EXE file your can run -- no install necessary.
Windows 7/Vista/XP/2003/2010 compatible dummy SMTP server. Sits in the system tray and does not deliver the received messages. The received messages can be quickly viewed, saved and the source/structure inspected. Useful for testing/debugging software that generates email.
We use it for on our development systems and it works great.

- 2,978
- 12
- 44
- 49