53GB

Use GMAIL to send emails from Linux terminal and shell script



Use GMAIL to send emails from Linux terminal and shell script

How to Configure Linux to send emails from terminal and shell scripts using GMAIL as an external SMTP Server.

########### Use GMAIL SMTP server to send mails ##################

yum install -y mailx

Lets tell google we gonna send emails from other devices also.

https://myaccount.google.com/lesssecureapps

Edit

vim /etc/mail.rc

#———– add the below lines and append as per your credentials.

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/

Update the gmail account credentails over here and save

# Now we are all done , we will be using gmail to send email from our linux box.

echo “Relay Test” | mail -v -s “Relay test” anyworkingemailid@anydomain.com

anyways… you send it to multiple domains now..

Rememeber … From email id will be the same that you have configured within /et/mail.rc file

Exit mobile version