Configure Amazon Linux server to send SMTP emails using gmail

1) Make sure your hostname reflects your public dns record

We edited our DNS to have a public dns of ""

So, we edited key file:

sudo nano /etc/sysconfig/network

and did a "sudo reboot"

2) Install SSMTP

sudo yum install ssmtp

3) Configure ssmtp.conf

a) sudo nano /etc/ssmtp/ssmtp.conf

b) Change:



4) If you have problems, turn on debug mode

In ssmtp.conf, put first line: Debug=Yes

It will log everything to:

sudo nano /var/log/maillog

5) Edit ./etc/ssmtp/revaliases

root:Devin Johnson<>

6) Edit php.ini

a) sudo nano /etc/.php.ini

b) Search on "mail function"

c) Change sendmail_path to point to ssmtp

sendmail_path = /usr/sbin/ssmtp -t -f ''

6) If you can send emails, but the name of the "from" email is Apache, add this to your PHP:

$headers = 'From: Devin Johnson<>' . "\r\n" .

'Reply-To:' . "\r\n" .

'X-Mailer: PHP/' . phpversion();

mail($email,$subject,$strBody, $headers);