Postfix – Stopping Outgoing Delivery While Accepting Incoming

mac-osxpostfixsmtp

I'm doing development for a webapp that sends emails out to users. I've typically used Argosoft Mail Server (Freeware) in a windows environment as an SMTP server in which I've enabled relay but shutdown actual delivery. This allow me to point my webapp to my local server, and am able to validate all emails that are sent out by looking at the outgoing queue. Additionally, to be 100% safe, I would put in a non-existant DNS server to use to ensure that if I ever accidentally enable delivery, the server would still not be able to look up any external addresses and deliver the mail.

Now that I am doing development on an OSX machine, I'm looking for a similar solution. By default, OSX comes with Postfix installed, so I figured I would just use that and configure it similarly. However, I cannot seem to find an option anywhere to disable all outgoing email. Essentially, I want to set up Postfix as an open relay server, but disable delivery of all email. I can then look at the outgoing queue and see if the email(s) are as expected.

Is there anyway to easily accomplish this? Or is there a better solution I can use?

Best Answer

Put All Out Going Email On Hold

  1. In main.cf, put following check_recipient_access as first option of smtp_sender_restrictions 2

    smtpd_sender_restrictions =
        check_recipient_access regexp:/etc/postfix/onhold
        ...
        ...
    
  2. Create /etc/postfix/onhold with following content

    /example\.com$/ DUNNO
    /^/ HOLD
    

Everything will be put into hold queue, except email for example.com.

Base on postfix site, change

queue_run_delay = 3600

300 is default, which is 5min. Change it to 3600 will make it retry once per hour. You can try change it to 86400(24hr). I think that should give you enough time for testing and inspecting email contect.