SSMTP is a great send-only sendmail alternative.
AuthMethod=LOGIN
root=martinhearn@gmail.com
mailhub=smtp.gmail.com:587
rewriteDomain=gmail.com
hostname=localhost
UseTLS=Yes
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt
UseSTARTTLS=Yes
AuthUser=martinhearn@gmail.com
AuthPass=idzobjmopztgavcf
FromLineOverride=YES
@todo change this AuthUser= is the username which authenticates AuthPass= is the password for the user above FromLineOverride= is needed to allow the user to specify their own From: address (Gmail does not allow the user to specify their own From: address) mailhub= is the smtp server through which we are going to send the emails. the port is optionally needed. UseSTARTTLS= is to make a secure connection. Gmail needs it. Others settings: rewriteDomain= where will the mail seem to come from hostname= the full hostname of the machine
echo “test†| ssmtp -vvv recipient@address.com
ssmtp recipient@address.com < filename.txt
on centos:
tail -f /var/log/maillog
Edit/add this line to your php.ini
file
sendmail_path=â€/usr/sbin/ssmtp -tâ€
You must install mailutils after ssmtp:
# Centos
yum install mailx
# Ubuntu/Debian
sudo apt-get install mailutils
Test:
echo "Message Body" | mail -s "Message Subject" receiver@example.com