SSMTP is a utility that allows you to send emails through an SMTP account on an external server. For web development, it can be useful if you need to send emails to actual email addresses instead of placeholders.
Installation and configuration
1. First, install SSMTP. On Ubuntu and Debian-like systems, this is done with:
sudo apt-get install ssmtp
2. Edit the file /etc/ssmtp/ssmtp.conf
. For Gmail, it should look like this:
root=YOUR_EMAIL@gmail.com
mailhub=smtp.gmail.com:587
hostname=smtp.gmail.com:587
UseSTARTTLS=YES
AuthUser=YOUR_EMAIL@gmail.com
AuthPass=YOUR_PASSWORD
FromLineOverride=YES
3. Edit the file /etc/ssmtp/revaliases
:
root:YOUR_EMAIL@gmail.com:smtp.gmail.com:587
www-data:YOUR_EMAIL@gmail.com:smtp.gmail.com:587
YOU_USER:YOUR_EMAIL@gmail.com:smtp.gmail.com:587
This entry specifies how emails should be sent by different system users.
4. Modify /etc/php5/apache2/php.ini
. Add or modify the line:
sendmail_path = /usr/sbin/ssmtp -t
5. Restart your web server:
sudo service apache2 restart
After restarting your web server, emails will be sent using Gmail.