Setup with sendmail

Install sendmail and dependencies

The SASL2 binaries are required for outgoing authentication. Run the following to ensure that sendmail and all necesasry dependencies are installed:

apt-get update
apt-get -y install sendmail sasl2-bin openssl

Setup /etc/mail/access

In order to relay email through our smarthost, you'll need your username and password stored in /etc/mail/access.
Edit /etc/mail/access. Add the following lines to the end of the file, replacing YourUsername and YourPassword with the values you were provided with:

# Authentication info for "U:YourUsername" "P:YourPassword" "M:PLAIN"


Edit /etc/sendmail/

Add smarthost


Search for these two lines:

dnl # The access db is the basis for most of sendmail's checking
FEATURE(`access_db', , `skip')dnl

And replace them with these: 

dnl ### BEGIN Add content for
define(`SMART_HOST', `')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 25')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 25')dnl
dnl ### END Add content for

Add authentication header

It's necessary for sendmail to pass a special header to our MTA, to ensure your email is correctly authenticated. Still in /etc/sendmail/, search for a line reading MAILER_DEFINITIONS, and add the following above this line: 

dnl #### BEGIN Add header for
LOCAL_CONFIG<span class="fr-marker" data-id="0" data-type="false" style="display: none; line-height: 0;"></span><span class="fr-marker" data-id="0" data-type="true" style="display: none; line-height: 0;"></span>
HX-AuthUser: ${auth_authen}
dnl #### END Add header for

Save and exit /etc/sendmail/

Apply config

Apply your updated config, by running:

cd /etc/mail

Expect a lot of verbose output the first time around. Run make again, and confirm the output looks cleaner, as below: 

root@bf480e24bc8a:/etc/mail# make
Creating /etc/mail/relay-domains
# Optional file...
A forced reload...
** ** You should issue `/etc/init.d/sendmail reload` ** **

Restart sendmail

Run /etc/init.d/sendmail reload to restart sendmail

Send test email

From the command line, you can send a test email to yourself, by running the following (replacing <your-email-address> with a real one):

apt-get install bsd-mailx
echo "Hello, I am your test" | mail -s "Test email via" <your-email-address>

Check the contents of /var/log/mail.log to confirm successful delivery. Below is a sample log from a successful delivery: 

Mar 22 19:32:39 ubuntu-bionic sendmail[8323]: x2MJWcdt008323: from=vagrant, size=144, class=0, nrcpts=1, msgid=<>, relay=root@localhost
Mar 22 19:32:39 ubuntu-bionic sm-mta[8324]: x2MJWdB8008324: from=<>, size=426, class=0, nrcpts=1, msgid=<>, proto=ESMTP, daemon=MTA-v4, relay=localhost []
Mar 22 19:32:39 ubuntu-bionic sendmail[8323]: x2MJWcdt008323:, ctladdr=vagrant (1000/1000), delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=30144, relay=[] [], dsn=2.0.0, stat=Sent (x2MJWdB8008324 Message accepted for delivery)
Mar 22 19:32:40 ubuntu-bionic sm-mta[8326]: STARTTLS=client,, version=TLSv1.2, verify=FAIL, cipher=ECDHE-RSA-AES256-GCM-SHA384, bits=256/256
Mar 22 19:32:42 ubuntu-bionic sm-mta[8326]: x2MJWdB8008324: to=<>, ctladdr=<> (1000/1000), delay=00:00:03, xdelay=00:00:03, mailer=relay, pri=120426, [], dsn=2.0.0, stat=Sent (Ok: queued as 410d939b-4cd9-11e9-9a10-d1cb19a74d67)