Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Put All Out Going Email On Hold

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

    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.

share|improve this answer
    
Won't that actually discard the email and not queue it anywhere? Hence no way to actually check the contents of the email in that case? –  Eric B. Dec 26 '12 at 6:58
    
That is correct, all out going email is discarded. But email for local mailbox will be delivered correctly. Assuming you configure postfix to accept email for example.com. Then email for user@example.com will still be delivered to its local mailbox. Let me know if you have additional requirement. –  John Siu Dec 26 '12 at 7:27
    
Revised, I didn't see you want outgoing to be queued. –  John Siu Dec 26 '12 at 7:44
    
I've tried your suggestion but to be safe, set my relayhost = disable.relay just in case. I've tried sending a test email to a gmail account, but instead of being dropped in the hold queue, I see it logged as being deferred since "Host or domain name not found. Name service error for name=disable.relay type=AAAA: Host not found". I would have expected it to go directly into the hold queue and not even check against the relay server. Is there any way to validate this? –  Eric B. Dec 27 '12 at 4:41
    
I also just noticed that since it sits in a deferred queue, postfix tries to resend it every 5 mins, which gets a little annoying. Anyway to fix this? –  Eric B. Dec 27 '12 at 4:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.