Configuring Discourse to use Mailsac SMTP

At Mailsac, we try to dogfood our products. When I was configuring this Discourse forum I was a little disappointed with the lack of documentation for configuring Discourse with a custom SMTP provider.

The Discourse cloud install guide suggests using a few recommended email providers. Since Mailsac is an email provider, I wanted to send through our own platform.

Mailsac Configuration

  1. Create an Custom Domain in Mailsac
  2. Configure DNS in Mailsac using the provided DKIM, MX, and SPF records in the DNS Setup tab.
  3. Create private address for Discourse to send from
  4. Grab your Mailsac API Key for SMTP authentication.

Discourse Configuration

I followed the official cloud install guide from Discourse

SMTP configuration

Hostname for your Discourse? [discourse.example.com]: forum.mailsac.com
Email address for admin account(s)? [me@example.com,you@example.com]: mjmayer@team.mailsac.com 
SMTP server address? [smtp.example.com]: out.mailsac.com
SMTP port? [587]: 587
SMTP user name? [user@example.com]: discourse@forum.mailsac.com
SMTP password? [pa$$word]: pa$$word
Let's Encrypt account email? (ENTER to skip) [me@example.com]: skipped
  1. Open a web browser and navigate to your Discourse hostname and configure you admin account. You should receive an email from your Mailsac email account.

I’d love to hear about your experiences configuring Mailsac to work with your own applications.

A few questions sir:

  1. Why was it required to enter your mjmayer@team.mailsac email address? Since you aren’t sending from that. Was that intended to be copy+pasted?
  2. Usually you have to fill out both the SMTP user name and SMTP FROM address. Where is the FROM address configured?
  3. Did you need to configure TLS anywhere? Or does Discourse expect that.
  1. The mayer@team.mailsac.com address is the address I am using for my discourse account. When Discourse is initially setup registration to the forum is restricted to addresses entered in the field Email address for admin accounts
  2. Discourse assumes that SMTP username and the SMTP FROM are the same. If you are sending through the Mailsac SMTP server, the username and SMTP FROM will be the same. But if you are using a service that have a different SMTP username and SMTP FROM address the SMTP From can be configured by editing the configuration file (app.yml) for Discourse.
## Any custom commands to run after building
run:
  - exec: echo "Beginning of custom commands"
  ## If you want to set the 'From' email address for your first registration, uncomment and change:
  ## After getting the first signup email, re-comment the line. It only needs to run once.
  # - exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
  - exec: rails r "SiteSetting.notification_email='fromAddress@forum.mailsac.com'"
  - exec: echo "End of custom commands"
  1. TLS does not need to be configured. Discourse assumes TLS by default.