How to configure an SMTP Black Hole

Requirement:  Build a web server that will receive email for a particular domain and discard it immediately (and silently).

I started with a canned Debian 9 system at OVH, but this should work with other and older Debian versions too.

Log in as root and make sure you’re all up to date:

apt-get update && apt-get upgrade

Set your hostname.

hostname fake
echo "" > /etc/hostname

Install postfix

apt-get -y install postfix
# Use the below as a guide for any configuration questions.  You will probably only see the first two unless you do a 'dpkg-reconfigure postfix'.
# on the "General type of mail configuration" screen, select "Internet Site"
# on the "System mail name:" screen, accept the default of "localdomain".
# on the "Root and postmaster mail recipient:" screen, leave the field blank.
# on the "Other destinations to accept mail for (blank for none):" screen, remove your hostname from the list so that it reads "localhost, localhost.localdomain"
# on the "Force synchronous updates on mail queue?" screen, select "No" because we don't care about the mail queue.  Like at all.
# on the "Local networks:" screen, accept the default " [::ffff:]/104 [::1]/128" entry.
# on the "Mailbox size limit (bytes):" screen, accept the default "0".
# on the "Local address extension character:" screen, accept the default "+".
# on the "Internet protocols to use:" screen, choose whatever applies to you.  The default of "all" is probably OK.

Now we can configure aliases and postfix.

echo "devnull: /dev/null" > /etc/aliases
echo " devnull@localhost" > /etc/postfix/virtual
postmap /etc/postfix/virtual
echo " /dev/null" > /etc/postfix/vmailbox
postmap /etc/postfix/vmailbox
echo "virtual_mailbox_domains =" >> /etc/postfix/
echo "virtual_mailbox_base = /var/mail/vhosts" >> /etc/postfix/
echo "virtual_mailbox_maps = hash:/etc/postfix/vmailbox" >> /etc/postfix/
echo "virtual_minimum_uid = 100" >> /etc/postfix/
echo "virtual_uid_maps = static:5000" >> /etc/postfix/
echo "virtual_gid_maps = static:5000" >> /etc/postfix/
echo "virtual_alias_maps = hash:/etc/postfix/virtual" >> /etc/postfix/
postfix reload

Now watch the mail log and see everthing addressed to go to /dev/null

tail -f /var/log/mail.log

Example log entries for an email going to /dev/null:

Jun 27 15:09:09 fake postfix/smtpd[3449]: connect from[]
Jun 27 15:09:09 fake postfix/smtpd[3449]: 355BB1F4F6:[]
Jun 27 15:09:09 fake postfix/cleanup[3454]: 355BB1F4F6: message-id=<>
Jun 27 15:09:09 fake postfix/qmgr[3446]: 355BB1F4F6: from=<>, size=19947, nrcpt=1 (queue active)
Jun 27 15:09:09 fake postfix/local[3455]: 355BB1F4F6: to=<devnull@localhost>, orig_to=<>, relay=local, delay=0.22, delays=0.22/0.01/0/0, dsn=2.0.0, status=sent (delivered to file: /dev/null)
Jun 27 15:09:09 fake postfix/qmgr[3446]: 355BB1F4F6: removed
Jun 27 15:09:09 fake postfix/smtpd[3449]: disconnect from[] ehlo=2 starttls=1 mail=1 rcpt=1 data=1 quit=1 commands=7

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *