Simulate a black hole for a domain with Postfix

From Deimos.fr / Bloc Notes Informatique
Jump to: navigation, search
Postfix

Software version 2.10
Operating System Debian 7
Website Postfix Website
Last Update 07/05/2013
Others

1 Introduction

When you manage outgoing emails through SMTP, you may sometimes need to test if a service is able to send correctly emails and itself check that there were no issue during sending. You can create a black hole for a specific domain and Postfix will answer from the same manner as if it is ok. It also permit to test Postfix sending capacities on a server.

2 Installation

Of course you need Postfix :

Command
aptitude install postfix

3 Configuration

In the Postfix main configuration, add transport map line :

Configuration File /etc/postfix/main.cf
[...]
transport_maps = dbm:/etc/postfix/blackhole_map
[...]

Now add the fake domain to the transport map file :

Configuration File /etc/postfix/blackhole_map
blackhole.com     discard:silently

Let's generate the map now :

Command postmap
postmap -c /etc/postfix /etc/postfix/blackhole_map

Now restart postfix and you will see in your logs something like this :

postfix/discard[1435]: [ID 897546 mail.info] 4D847A5B: to=<john@blackhole.com>, relay=none, delay=13, delays=13/0/0/0, dsn=2.0.0, status=sent (silently)

4 References

http://www.memoire-partagee.fr/2011/01/smtp-sortant-faire-un-trou-noir-avec-postfix/