Thursday, February 1, 2018

Send emails from PHP with ssmtp

The installation process:

sudo apt-get install ssmtp

Then edit the /etc/ssmtp/ssmtp.conf file with this information:
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES
AuthUser=<YOUR-EMAIL>@gmail.com
AuthPass=<YOUR-PASSWORD>
(or any other SMTP-server that you might want to use)

Final steps:
Find your php.ini file (usually in /etc/php5/cli/php.ini) and make sure the sendmail_path is:

sendmail_path = /usr/sbin/sendmail -t

Then restart your apache2-server with


service apache2 restart


In my case, I've got a hosted server so I needed to edit this file :
/etc/ssmtp/ssmtp.conf
Then uncomment this line :

FromLineOverride=YES

No comments:

Post a Comment