Install SSMTP on Centos 7
| August 31st, 2016Add the repo if it’s not added:
yum install epel-release -y
Install:
yum -y install ssmtp (yum install mailx) if not installed
Configure:
alternatives --config mta
There are 2 programs which provide 'mta'. Selection Command ----------------------------------------------- *+ 1 /usr/sbin/sendmail.postfix 2 /usr/sbin/sendmail.ssmtp Enter to keep the current selection[+], or type selection number:
2
Disable postfix (or sendmail):
systemctl stop postfix systemctl disable postfix
Edit SSMTP config file: (/etc/ssmtp/ssmtp.conf)
root=postmaster TLS_CA_File=/etc/ssl/certs/ca-bundle.crt #check your certificate path mailhub=smtp.gmail.com:587 # SMTP server for Gmail Hostname=localhost UseTLS=YES UseSTARTTLS=Yes FromLineOverride=YES #TO CHANGE FROM EMAIL Root=ROOT@EMAIL # Redirect root email AuthUser=EMAIL@gmail.com AuthPass=PASSWORD AuthMethod=LOGIN RewriteDomain=gmail.com
Test:
echo "TEST EMAIL" | mail -s "SSMTP IS WORKING" TEST@gmail.com
Probably we’ll get this error:
send-mail: Authorization failed (534 5.7.14 https://support.google.com/mail/answer/78754 r142sm8267633wme.10 – gsmtp)
and Maybe an email to your gmail account with the title: Review blocked sign-in attempt. This is because you have to authorize the App. To do so follow this link: https://support.google.com/accounts/answer/6010255
Update:
Seems there is problem with SSMTP and passwords containing special characters such as “#,$,*…”