Using SparkPost with Discourse

April 29, 2017 Contributors

To use SparkPost with Discourse you’ll need to:

  • Sign up for a SparkPost account
  • Create and verify a sending domain in SparkPost
  • Create an API key in SparkPost
  • Install Discourse
  • Update the SMTP credentials in your Discourse config
  • Change the default from email Discourse uses to send messages

Sign up for a SparkPost account

Visit our sign up page and create your SparkPost account. It’s free up to 15,000 emails!

Create and verify a sending domain

Visit the Sending Domains page and create a new domain. To verify your domain, do one of the following:

  • Sending a verification email to abuse@yourdomain.com
  • Sending a verification email to postmaster@yourdomain.com
  • Setting up a valid DKIM DNS record

Choose the method that works best for you. View this support article for more detailed information on setting up sending domains.

Create an API key in SparkPost

Visit the API Keys page and create an API key with the “Send via SMTP” permission:

Install Discourse

There are lots of links available on the web for installing Discourse so this article won’t provide a detailed walkthrough. If you’re starting from scratch we highly recommend this article: How to use the Discourse One-Click Application on DigitalOcean.

If you follow that guide, you’ll be prompted for SMTP credentials. Use the following information:

Where YOUR-API-KEY is the key you created above with the “Send with SMTP” permission.

Update the SMTP credentials in Discourse

If you have an existing installation of Discourse, open up your Discourse installation’s app.yml file and update the following settings:

Where YOUR-API-KEY is the key you created above with the “Send with SMTP” permission.

Change the default from email Discourse uses

By default, Discourse will send email from the hostname you configured Discourse with. For instance, if you set the DISCOURSE_HOSTNAME setting to ‘discourse.mysite.com’, Discourse will send emails with the from address noreply@discourse.mysite.com.

To change this, uncomment and edit this line in your Discourse installation’s app.yml file:

Note that you should replace “your-sending-domain.com” with the sending domain you created and verified earlier.

You’ll need to issue a rebuild after uncommenting the above line and setting the from email address as required.

Go forth and send!

Your Discourse installation should now be configured to send email through SparkPost.