The situation required me to use an existing MS Exchange Server as a mail relay to send an email from a custom notification shell script I’m working on.
I tried configuring Postfix, Sendmail, Mailx, Nail, all to no avail. This took quite some time in troubleshooting and Google was not particularly helpful.
Eventually I stumbled across this post, which mentioned using the EPEL repo’s to install SSMTP. Simple, but effective.
Therefore, this entry focuses on how to setup your server to relay mail, using the SSMTP package (because it works)
0. Login as root or su.
1. Check to ensure that the permissions are correct to relay mail.
telnet my.emailserver.ip.address 25
MAIL FROM: email@example.com
RCPT TO: firstname.lastname@example.org
This is a test message.
. <Hit Enter>
You should have received an email if the permissions are correct.
2. Install the EPEL repo
Please use this alternative if the original does not work. – http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh epel-release-5-4.noarch.rpm
3. Remove sendmail
yum remove sendmail
4. Install SSMTP
yum install ssmtp –enablerepo=EPEL
Backup original conf file
cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.bkp
Edit the conf file
Edit the following lines:
*Depending on your configuration, you may or may not need TLS, check the SSMTP.conf man for details.
6. Restart service
service ssmtp restart
7. Test the application
echo “This is the body of my email” | ssmtp email@example.com
This worked for me where all the others mysteriously failed. Now I’m off to finish my script. I’ll post another update soon!