• How to configure SendMail to use an SMTP Relay

This article gives the steps to setup SendMail to use an SMTP relay also known as Smart Host to send out email through. If you don't have your own SMTP relay then your ISP SMTP Relay can be used. Although, keep in mind you may have to pass credentials to use your ISP or maybe even your enterprise SMTP relay.

This is useful when sending emails to external recipients to avoid anti-spoof and anti-spam filters to drop the messages because they are not coming from a whitelist SMTP relay. Be default it would use it's local SMTP mechanism which generally will be blocked by most SMTP systems.

Prerequisites

sendmail
sendmail-cf _The files needed to reconfigure SendMail_

Add SMTP Relay

Edit Sendmail Make file /etc/mail/sendmail.mc

vim /etc/mail/sendmail.mc

Remove Comment for the following lines

dnl define(`SMART_HOST', `smtp.your.provider')dnl

Replace smtp.your.provider

Example:

define(`SMART_HOST', `relay.mydomain.com')dnl

Do not use IP Address. It must be a FQDN. Beware of your DNS MX records causing issues.

Regenerate SendMail Configuration File /etc/mail/sendmail.cf

    /etc/mail/make

Add Authentication (Optional)

If the SMTP relay requires authentication then do the following steps.

Change to mail configuration directory

cd /etc/mail

Create /etc/mail/authinfo

vim /etc/mail/authinfo

Add a plain text line with SMTP FQDN and Credentials. Replace smtp.domain.com, USERNAME and PASSWORD

AuthInfo:smtp.domain.com "U:USERNAME" "P:PASSWORD" "M:PLAIN"

Create a hash map

makemap hash authinfo < authinfo

Add Authinfo to sendmail config

vim /etc/mail/sendmail.mc

FEATURE(`authinfo')

Regenerate SendMail Configuration File /etc/mail/sendmail.cf

/etc/mail/make

Restart Service with the appropriate command for your flavor and version of Linux.

service sendmail restart

/etc/init.d/sendmail restart

systemctl restart sendmail

This article was last modified: May 4, 2018, 8:45 a.m.

0 Comments

Please log in to leave a comment.

Add or change tags.

A comma-separated list of tags.

Share

Hacker News

Top