Saturday, July 10, 2010

Using Sendmail to Relay Mails from Your MSP/ISP in Centos, RHEL, Ubuntu and Other Linux Distros

Do you want to relay mails from your local sendmail server to your ISP. Just follow the below steps

Open sendmail.mc using default editor vi, edit, emacs
# vi /etc/mail/sendmail.mc

define(`SMART_HOST',`[smtp.yourisphost.com]')
FEATUREdnl

Save the File and exit
Open the File authinfo (If not Present Create a New File).


vi /etc/mail/authinfo
Add the following Line
"AuthInfo:smtp.yourisphost.com "U:UsernamefromISP" "P:passwordfromISP" "M:LOGIN PLAIN"

Save the File and Exit

Just run the below commands to recreate the sendmail.cf file

# cd /etc/mail/
# m4 sendmail.mc > sendmail.cf

Make Map will recreate the database for authinfo to be used in sendmail

# makemap hash /etc/mail/authinfo < /etc/mail/authinfo

Restart the Sendmail Service and check if All's Good !!!

# /etc/init.d/sendmail restart


echo '/map authinfo AuthInfo:smtp.yourisphost.com' | /usr/sbin/sendmail -bt



Sent Mail Check in Logs

Enjoy.....

Comment if issues or modification required.

No comments:

Post a Comment