TUTORIAL SparkPost as a SendMail relay

jpstaub

New Member
Joined
Apr 8, 2016
Messages
9
Reaction score
4
Background: Initially I had a great deal of difficulty configuring SendMail to use SparkPost as an email relay. So much so that SSMTP was tested and evaluated as a replacement for SendMail. While SSMTP proved much easier to set up, the path to incorporating it into the Incredible PBX system was not clear. Additionally, Mr. Mundy did not recommend the SSMTP path. As a result, further effort was expended on SendMail. Fortunately, SendMail was made to work with SparkPost as an email relay.

Beware: The information included below produced a working solution. However, my understanding of exactly why the system works the way it does is incomplete. Use at your own risk!

Prerequisites:
  1. Incredible PBX 13-12.5 for Raspberry Pi 2 (other Incredible PBX versions on other hosts may work just as well)
  2. SparkPost account
  3. Domain name from a favorite domain name service provider
  4. Verified sending domain (follow SparkPost instructions)
  5. SparkPost API_key allowing SMTP connections (follow SparkPost instructions)
  6. Ability to establish an SSH connection with Incredible PBX as root user
  7. Incredible PBX Webmin access (not absolutely necessary but helpful)
Process:
Configuring Gmail as a SendMail email Relay was used as the instructional template. "STEP" below refers to steps in the instructional template.
  1. Establish an SSH connection with Incredible PBX as root user.
  2. Make a backup of "sendmail.mc" (nice to have something good to go back to).
  3. No need to repeat STEP 2. SendMail should be installed.
  4. Create SparkPost authentication file following STEP 3 using information below.
    1. AuthInfo: "U:root" "I:SMTP_Injection" "P:SparkPost_API_key"
  5. Configure SendMail following STEP 4.
    1. Optional - use Webmin to alter sendmail.mc. Log-in as root then Servers>>Sendmail Mail Server>>Sendmail M4 Configuration
    2. Under 'SMART_HOST' replace "smtp.gmail.com" with "smtp.sparkpostmail.com"
    3. Ensure masquerade options at the end of the file are set so that MASQUERADE_AS is set to the SparkPost verified sending domain. SparkPost looks for this domain specifically and will not work without it.
      1. MASQUERADE_AS(`VERIFIED_SENDING_DOMAIN')dnl
    4. Configuration file can be rebuilt using Webmin
  6. Test SendMail following STEP 5.
  7. See '/var/mail/root' to troubleshoot if email is not reaching destination.
How "sparkpost-auth" file should look:
Code:
AuthInfo: "U:root" "I:SMTP_Injection" "P:SparkPost_API_Key"

How "sendmail.mc" should look from Default Mailer setup to the end of the file:
Code:
dnl # Default Mailer setup
MAILER_DEFINITIONS
define(`SMART_HOST',`[smtp.sparkpostmail.com]')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
define(`confAUTH_OPTIONS', `A p')dnl
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo',`hash -o /etc/mail/authinfo/sparkpost-auth.db')dnl
MAILER(`local')dnl
MAILER(`smtp')dnl

dnl # Masquerading options
FEATURE(`always_add_domain')dnl
MASQUERADE_AS(`VERIFIED_SENDING_DOMAIN')dnl
FEATURE(`allmasquerade')dnl
FEATURE(`masquerade_envelope')dnl

Frankly, I have no idea what's going on when it comes to the security portion of the configuration file. People who know more will have to fill in the blanks. Happy hunting.
 
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top