Red hat linux Shell scripting

Send E-Mail On Redhat / CentOS with SMTP (SMTP Relay)

In this tutorial we will send email with mailx and using external SMTP server for email sending from CentOS/Redhat

Install mailx

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


set smtp=smtps://
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

Leave a Reply

Your email address will not be published. Required fields are marked *