I personally use very simple and lightweight package ssmtp. It will use any smtp server to send outbound emails. Install it by running:
sudo apt-get install ssmtp
Then edit /etc/ssmtp/ssmtp.conf
file, comment out existing mailhub line and add the following lines (this example is for gmail smtp server):
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES
AuthUser=<YOUR-EMAIL>@gmail.com
AuthPass=<YOUR-PASSWORD>
(Provide your gmail username & password. Of course you can use any other SMTP server).
Now make sure that your php.ini has correct sendmail_path
. It should read as:
sendmail_path = /usr/sbin/sendmail -t
(You do not have to specify ssmtp
here because the installation should have created a symlink for /usr/sbin/sendmail
, which correctly points to ssmtp
. Otherwise you have to specify sendmail_path = /usr/sbin/ssmtp -t
)
Also make sure your server has port 25 UDP open (default port for SMTP. might need to contact your hosting for this)
Reload apache and your php should be able to send outgoing emails now.