Linux: SMTP for Server Email

When setting up a server that needs to send emails, it’s sometimes more useful to have it send those emails via SMTP (using a service like Gmail or AWS SES) but often the php default is not this. So let’s learn how install and setup secure email sending capabilities for our php based applications on a linux server.

First, login to your server, locally or remotely (e.g. ssh root@example.com). Once you’re in, we’ll want to install ssmtp, then edit the configuration file for our STMP service.

1) apt-get install ssmtp
2) cd /etc/ssmtp/
3) cp ssmtp.conf ssmtp.conf.bak
4) nano ssmtp.conf

–These are the valid setting for Gmail and Amazon SES–

Gmail:

root=administrator@example.com
mailhub=smtp.gmail.com:465
AuthUser=administrator@example.com
AuthPass=XXXXXXXXX
UseTLS=Yes

Amazon SES (US East):

root=administrator@example.com
mailhub=email-smtp.us-east-1.amazonaws.com:465
hostname=example.com
AuthUser=AKBXXXXXXXXXXXXXXXXX
AuthPass=AnPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
FromLineOverride=yes
UseTLS=yes

Leave a Reply

Your email address will not be published. Required fields are marked *