How to send test email when using Discourse forum software

Introduction

If you make use of Discourse as your forum software you need to set up an SMTP server. When developing or testing the forum you want to make sure you don't accidentally email real folks.

Discourse can be set up to use Imitate Email by configuring the SMTP settings correctly. Setting up Imitate Email as your test SMTP server is very easy to do:

Step 1: Set up Imitate Email

If you've not already done so please sign up to Imitate Email.

Step 2: Locate your mailbox credentials

Your username

To locate your username go to Settings > My Mailbox where you will find it (it is the same for all mailboxes in your account)

For the password

If you're on the Free or Developer plan or you're setting this up for your personal mailbox copy the password from the same place as the username.

If you're setting this up for a team mailbox go to Settings > Projects and you will find the password next to the symbol for your mailbox. It will look like the following 6bcb69b2-08ac-4c67-911a-10442f7d84b3

Screenshot of Imitate Email personal settings

Step 3: Configure SMTP for Discourse

Setting up a new installation of Discourse

When you launch the set up tool using ./discourse-setup you will be prompted for your email settings, as follows:

Hostname for your Discourse? [discourse.example.com]: 
Email address for admin account(s)? [me@example.com,you@example.com]: 
SMTP server address? [smtp.example.com]: smtp.imitate.email
SMTP port? [587]: 587
SMTP user name? [user@example.com]: <copy your username from the previous step>
SMTP password? [pa$$word]: <copy your password from the previous step>
Let's Encrypt account email? (ENTER to skip) [me@example.com]: 
Optional Maxmind License key () [xxxxxxxxxxxxxxxx]:

Once you've gone through that, you will have an app.yml configuration file created at /containers/app.yml. If you need to change those settings in the future you can follow as below:

Configuring an existing installation of Discourse

  1. Locate your app.yml file (it should be in /containers/app.yml)

  2. Edit the file and change the SMTP settings section so that it looks like:

DISCOURSE_SMTP_ADDRESS: smtp.imitate.email
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: <your username from Step 2>
DISCOURSE_SMTP_PASSWORD: <your password from Step 2>
DISCOURSE_SMTP_ENABLE_START_TLS: true  
DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none
DISCOURSE_SMTP_DOMAIN: imitate.email
  1. Don't forget to:
./launcher rebuild app
  1. That's it!