Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm developing a web application in PHP, and my Macbook, running Snow Leopard, is actually sending emails when PHP's mail() function is called. It's emailing customers, and that's BAD.

I COULD prevent this in my code, but I'd rather just disable mailing for my machine. Is there a way to do this under Mac OS?

share|improve this question
2  
If you're doing development on your macbook, you should really not have customer information in the db. Only test data should be in there. Imagine how much could be compromised if you lost your laptop, or worse, it was stolen. –  davethegr8 Dec 15 '09 at 22:47

4 Answers 4

up vote 3 down vote accepted

The simplest answer is to have a switch in your send logic that checks whether or not DEVELOPMENT is defined. If it is, it outputs the mail to a file, other wise, it assumes a production environment and continues with the normal send process.

All you need to do is set DEVELOPMENT = TRUE in your config and you can play around without disturbing customers!

Your local postfix config is located in /etc/postfix. There seems to be a duplicate at /private/etc/postfix but i'm not so familiar with OSX. On linux i could just remove the daemon and stop the service from running. This might cause runtime errors for your programs and seems unecessary.

share|improve this answer
    
This is exactly what I ended up doing: 1) used an IS_DEVELOPER flag and 2) disabled postfix. Actually for (2), I moved /usr/sbin/sendmail to /usr/sbin/sendmail.original and put a dummy sh script in place of sendmail, as I read that sendmail uses Postfix when Postfix is running but can still send out emails otherwise. I don't need outgoing email functionality on this machine, so this solution works for me. –  Chad Johnson Dec 16 '09 at 1:13
2  
/etc/ is a symlink to /private/etc/ so they're the same file. (The same occurs with /var and /tmp as well on OS X). –  Chealion Dec 16 '09 at 4:34

Easiest thing I can think of (If you only use web mail or Imap), simply at the network (router) level block outgoing of port 25 from your machine, or use the OS X firewall and block port 25 outgoing.

IF this doesn't work, I would simply look at putting a non existent relay in to your php.ini so all mail simply fails to send....

However, you would be better off using a real relay that simply does not send out but looks like it does - blocking at the firewall or application or fake relay could all produce errors that you may not account for and cause problems when you do actually go live.

share|improve this answer

To partially disable postfix run sudo launchctl unload /System/Library/LaunchDaemons/org.postfix.master.plist

However the mail you're attempting to send will get stuck in /var/spool/postfix/maildrop but will not send.

share|improve this answer

You need to compartmentalize your development environment from your release environment.

That is the solution to your real problem.

share|improve this answer

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.