Walker News

How To Configure Sendmail To Relay Email To Exchange Server?

A simple intention goes like this: There are some scripts scheduled to run periodically on few Linux servers. Upon execution, the scripts will send output and failure notification as email to recipients’ mailbox on Exchange Server.

Apparently, Microsoft products dominate this corporate IT infrastructure. Instead of asking recipients login to various Linux servers for the said emails, you’re required to configure the Linux Sendmail to relay those emails to Microsoft Exchange Server.

Fortunately, it is not that hard to get this configuration done (probably fewer than 3 minutes).

Preliminary assumptions and requirements:

1) The Exchange Server is known as exchsvr.example.com 192.168.233.50

2) The corporate DNS servers are 192.168.233.40 and 192.168.233.41

3) The Linux networking is able to resolve hostname via DNS servers, i.e. the Linux server is able to do ping exchsvr.example.com and ping 192.168.233.50. To enable DNS resolution in Linux, edit /etc/resolv.conf and add in the DNS server. The sample of resolv.conf for this example:
nameserver 192.168.233.40
nameserver 192.168.233.41

4) Edit /etc/hosts file to include a line with IP, hostname, and FQDN (full qualify domain name) of the Linux server:
192.168.233.60   linux01  linux01.example.com

The FQDN doesn’t have to be already registered in your corporate DNS server, i.e. it can be anything you want at wish. Of course, if there is a legitimate record in DNS, then you should put that FQDN exactly in /etc/hosts. In some cases, the Sendmail / mailq might takes times to start up / complete.

5) RHEL 5.2 is used for this reference (but should be applicable to other Linux distributions with ease).

Step to configure Sendmail smart host to relay email:

1) Open sendmail.cf for edit
vi /etc/mail/sendmail.cf

2) Search for DS keyword to add Exchange Server as smart host:
DSexchsvr.example.com

3) Save the changes made.

4) Restart Sendmail service:
service sendmail restart

To test the email relay function, execute
mail -s "testing" your_exchange_email_address </dev/null

and check the Exchange mailbox (click the Inbox folder then press F9 to activate on-demand send/receive function).

Besides, you can also execute mailq at Linux server to see the mail queue status.

Custom Search

  1. Saumitra 21-05-10@18:42

    Through this solution you are not using the exchange relay facility , in fact your sendmail daemon itself relaying emails.

2014  •  Privacy Policy