Tuesday, September 11, 2018

Setup outgoing email using Rackspace SMTP for your ubuntu server using Postfix

Follow this very easy steps to send outgoing emails from your ubuntu server using Rackspace Email server SMTP.


Step 1 - Prepare required software

aptitude update apt-get install postfix libsasl2-modules

Step 2 - Configure Postfix's main.cf

Add the following to /etc/postfix/main.cf:
 relayhost = secure.emailsrvr.com
 smtp_sasl_auth_enable=yes
 smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd
 smtp_sasl_mechanism_filter = AUTH LOGIN
 smtp_sasl_security_options =

Step 3 - Set your username and password into sasl_password

Add the Rackspace Email username and password to /etc/postfix/sasl_passwd by running these commands:
echo 'secure.emailsrvr.com username@domain.com:secretpassword' > /etc/postfix/sasl_passwd
chmod 600 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd

Step 4 - Restart Postfix

service postfix restart

Step 5 - Send test email

echo "My message body" | mail -s "Test Email Subject" somebody@gmail.com
That is all... 5 easy steps will get your server sending email reliably using Rackspace Email account!