yum -y update
yum install -y mailx
We can now start sending e-mails using
create a symbolic link
ln -s /bin/mailx /bin/email
###Set an External SMTP Server to Relay E-Mails
vi /etc/mail.rc
edit
set smtp=smtps://smtp.gmail.com:465
set smtp-auth=login
set smtp-auth-user=USERNAME@YOURDOMAIN.COM
set smtp-auth-password=YOURPASSWORD
set ssl-verify=ignore
set nss-config-dir=/etc/pki/nssdb/
example usage :
echo "Your message" | mail -v -s "Message Subject" email@address
Thanks ilkereroglu for your sharing!
In my virtual instance, Linux CentOS 8 works perfectly, in case you want to configure a Gmail account with 2Factors enabled, it is needed to you the app password: error received:
535-5.7.8 Username and Password not accepted. Learn more at
smtp-server: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials a22sm8057227wmj.9 - gsmtp
smtp-server: 535 5.7.8 https://support.google.com/mail/?p=BadCredentials a22sm8057227wmj.9 - gsmtp
Article to follow in Google Help Center.