Stop postfix from sending email for testing

This applies to CentOS 6. You may want to do this when testing some code and you’re not sure if it is going to send emails or not.

Edit /etc/postfix/

Add following lines at the bottom:

myhostname = localhost
mydomain = localdomain
inet_interfaces = $myhostname, localhost
mydestination = $myhostname, localhost.$mydomain, localhost
mynetworks_style = host
default_transport = error:outside mail is not deliverable

Save the file then run the following commands (as root)

postfix upgrade-configuration
postfix check

Test by mailing something to yourself


Check that it just gets put in the root mailbox


Enter the number of the email you want to read and it appears, d to delete it, z to return to the list, q to quit.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.