smtp relayhost in OS X Yosemite

In order to send mail from a localhost, you would need to enable the smtp server as a host.

First you would have to edit the main.cf file to add in the relayhost

sudo vim /etc/postfix/main.cf

//Add the below code to after the commented relayhost code

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes

Next you would have to generate a sasl_password if it doesn’t exist

sudo vim /etc/postfix/sasl_passwd

add in the below to sasl_passwd

[smtp.gmail.com]:587 username@gmail.com:password

Lastly restart the postfix

sudo chmod 600 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd
sudo launchctl stop org.postfix.master
sudo launchctl start org.postfix.master

You might want to consider using sudo su - since root access is required for all the above operations.

Credit given to Anuj Gakhar.
Although the article was for Lion, it works for Yosemite too.

Advertisements
This entry was posted in Web Development and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s