Centos 6.6 sending email out from your gmail account
using ssmtp
For this example I will say my email gmail address is glen@gmail.com and my gmail password is
gmail_password, it is not btw. You will also need to enable/install the epel
repos for adding ssmtp and mailx
First uninstall postfix.
#
yum remove postfix
Now install ssmtp.
# yum
–y install ssmtp mailx
Now edit your /etc/ssmtp/ssmtp.conf.
I removed everything and just added the below in the file.
# vi /etc/ssmtp/ssmtp.conf
root=glen@gmail.com
mailhub=smtp.gmail.com:587
rewriteDomain=gmail.com
hostname=mycentserver.mydomain.domain
UseTLS=Yes
UseSTARTTLS=Yes
AuthUser=glen@gmail.com
AuthPass=gmail_password
FromLineOverride=YES
#
This solved if you get a ssmtp: Cannot open smtp.gmail.com:587 when try to send
an email
# if
you enabled uncommenting DEBUG=Yes line and your /var/log/maillog show
#
SSL not working: certificate verify failed (20) Uncomment the following line
but first
# VERIFY FILE EXISTS
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt
#
DEBUG=Yes
Now edit your /etc/ssmtp/revaliases file and add the
following.
# vi
/etc/ssmtp/revaliases
root:glen@gmail.com:smtp.gmail.com:587
Now run
# alternatives
--config mta
And choose the number for sendmail.ssmtp, like below
There
is 1 program that provides 'mta'.
Selection
Command
-----------------------------------------------
*+
1 /usr/sbin/sendmail.ssmtp
Enter
to keep the current selection[+], or type selection number: 1
#
Now send email to your gmail account from Centos cli
#
mail -s "Test Subject" glen@gmail.com
Type your message text and on new line press ctrl d to send
Remember to disable/remove your epel repos when done.
The End
No comments:
Post a Comment