Tuesday, September 15, 2009

How to: Sending Emails with MAMP PRO

Sometimes you may need to send an email with PHP. To do so you have to configure and start Postfix. Ok, you could read the Postfix documentation, but it´s a bag of hurt. An easier way getting Postfix run is using the configuration tool built into MAMP PRO.
If you want to use the PHP function mail() for sending emails to your own email address (like mail@johndoe.com) you just need to open MAMP PRO, go to Server -> Postfix and add the value "johndoe.com" (without quotes and the according domain name) into the field "Domain of outgoing mail".

If you want to send emails to any other addresses, activate the checkbox "Smart Host" and fill in the according fields:

Host: Fill in your server name for outgoing emails. This could be for instance "smtp.johndoe.com" (without quotes). Ask your provider if you are unsure about the server name.

User: Add the user name of your mail account.

Password: Add the password for your email user account.

Authentication: Leave to "None"

Click the button "Change Postfix configuration". Everything should work now. If it doesn't: Some providers do not allow Smart-Hosts, like Google and Gmail. So you should probably check this first.

Share/Save/Bookmark