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 outboundemailfilter.com AuthInfo:outbound.ouemfi.com "U:YourUsername" "P:YourPassword" "M:PLAIN"
Setup sendmail.mc
Edit /etc/sendmail/sendmail.mc
Add smarthost
/etc/sendmail/sendmail.mc
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 outboundemailfilter.com define(`SMART_HOST', `outbound.ouemfi.com')dnl FEATURE(`access_db')dnl define(`RELAY_MAILER_ARGS', `TCP $h 25')dnl define(`ESMTP_MAILER_ARGS', `TCP $h 25')dnl dnl ### END Add content for outboundemailfilter.com
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/sendmail.mc
, search for a line reading MAILER_DEFINITIONS, and add the following above this line:
dnl #### BEGIN Add header for outboundemailfilter.com 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 outboundemailfilter.com
Save and exit /etc/sendmail/sendmail.mc
Apply config
Apply your updated config, by running:
cd /etc/mail make
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` ** ** root@bf480e24bc8a:/etc/mail# root@bf480e24bc8a:/etc/mail#
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 outboundemailfilter.com" <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=<201903221932.x2MJWcdt008323@test.com>, relay=root@localhost Mar 22 19:32:39 ubuntu-bionic sm-mta[8324]: x2MJWdB8008324: from=<vagrant@test.com>, size=426, class=0, nrcpts=1, msgid=<201903221932.x2MJWcdt008323@test.com>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1] Mar 22 19:32:39 ubuntu-bionic sendmail[8323]: x2MJWcdt008323: to=test@test.com, ctladdr=vagrant (1000/1000), delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=30144, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (x2MJWdB8008324 Message accepted for delivery) Mar 22 19:32:40 ubuntu-bionic sm-mta[8326]: STARTTLS=client, relay=outbound.ouemfi.com., 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=<test@test.com>, ctladdr=<vagrant@test.com> (1000/1000), delay=00:00:03, xdelay=00:00:03, mailer=relay, pri=120426, relay=outbound.ouemfi.com. [54.69.62.154], dsn=2.0.0, stat=Sent (Ok: queued as 410d939b-4cd9-11e9-9a10-d1cb19a74d67)