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

2) The corporate DNS servers are and

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 To enable DNS resolution in Linux, edit /etc/resolv.conf and add in the DNS server. The sample of resolv.conf for this example:

4) Edit /etc/hosts file to include a line with IP, hostname, and FQDN (full qualify domain name) of the Linux server:   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:

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.

  2. Nasia 28-06-15@08:02

    thank you so much to explain this topic
    its very infomatic

  3. courtade 08-07-16@16:52

    Hello, thank you for this tuto.
    I have an error message : Deferred: 403 4.7.0 TLS handshake failed
    Could you help me ?

    … Connecting to mail.domaine.fr. via relay…
    220 SERVINICAS1.dom.domaine.fr Microsoft ESMTP MAIL Service ready at Fri, 8 Jul 2016 10:50:12 +0200
    >>> EHLO dom.domaine.fr
    250-SERVINICAS1.dom.domaine.fr Hello [172.17.xx.xxx]
    250-SIZE 37748736
    250-AUTH NTLM
    250 XRDST
    >>> STARTTLS
    220 2.0.0 SMTP server ready
    … Deferred: 403 4.7.0 TLS handshake failed.
    Closing connection to mail.domaine.fr.

  4. Walker 10-07-16@19:00

    starttls only work if both end (mail server and mail client) support and enable starttls, and there is matching/valid certificate.

2018  •  Privacy Policy