How to Send Email with MAMP

How to use the mail() php function to send mail.

This works and is REALLY easy! And can be undone later. It's just editing a text file. I know it's scary and advanced (I was scared and confused at first), but just do it. It's fine. And if it doesn't work, you can change it back. Simple! :)

  1. Shutdown MAMP completely
  2. Edit /etc/postfix/main.cf
    • Search for "relayhost"
    • Add relayhost = smtp.example.com
  3. Start up MAMP again

smtp.example.com is an example smtp server. It's different depending on your internet provider. I'm at Harvard now, so mine is: smtp.fas.harvard.edu.

I'm not really sure why this works, but here's what I think it's doing:
postfix is a mailserver that comes installed on your Mac (like php does). MAMP uses postfix to send emails. By setting up a relayhost, it tells postfix to send the emails from your current ISP because before it didn't know how to send the email and the email just got stuck in a queue.

So, now all those old emails should be in your inbox, or wherever you sent them to! :)

If you'd like to view your mail log, it should be here:
/var/log/mail.log

FYI: I'm running Mac Leopard OS X 10.5.7 on one of the new MacBooks (with the silver titanium cover and black rim around the screen).

Source: http://mikeryan.name/books/knowledge-base/web-server-generated-email-und...

Thanks to Mike for this! I didn't trust him at first because it seemed too easy, yet sophisticated, but it works!