Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 3.04 KB

HOWTO_EMAIL_CONFIGURATION.md

File metadata and controls

44 lines (30 loc) · 3.04 KB

Configuring email notifications

This guide explains how to configure Spoke to send email notifications. Email notifications are sent for account-related actions, to remind texters when they have messages to send and for data exports. See .[Data Exporting doc].(DATA_EXPORTING.md) in the /docs folder regarding setting up an AWS S3 'bucket' to receive exports.

If you auto-deployed to Heroku, the Mailgun add-on was automatically provisioned for you. To use it, follow the steps below.

If you host Spoke on AWS Lambda or your own server, you will need an SMTP server configured to send email. Follow the external SMTP server setup steps.

Mailgun setup (Heroku-only)

Skip this section if you are using your own SMTP server or hosting Spoke anywhere other than Heroku.

When you auto-deploy to Heroku, the Mailgun add-on is automatically provisioned with a sandbox domain. The sandbox domain can send email only to a list of specified email addresses. To configure Mailgun to actually send emails (without needing to manually specify the address of every Spoke user), you must configure a custom domain.

  1. Navigate to Add-Ons in your Heroku app and click on Mailgun, or run heroku addons:open mailgun.
  2. Click on Domains. Add a custom domain (often a subdomain like email.bartletforamerica.com, but not one that's already in use).
  3. Configure the provided TXT, MX, and CNAME records with your DNS provider. Mailgun periodically checks for DNS record creation, and also provides an option to trigger the check manually.
  4. Configure the following Mailgun environment variables:
  • MAILGUN_DOMAIN
  • MAILGUN_PUBLIC_KEY
  • MAILGUN_SMTP_LOGIN
  • MAILGUN_SMTP_PASSWORD
  • MAILGUN_SMTP_PORT
  • MAILGUN_SMTP_SERVER

See the environment variables reference document for more information. Some of these variables are set during Heroku auto-deploy, some are not. Confusingly, some of those that are set automatically are set with values for the sandbox domain and must be changed for production. The environment variables reference document specifies the correct value for each variable.

  1. Set the EMAIL_FROM environment variable. This is the email address users will see when they receive emails.

External SMTP server setup

Skip this section if you are using Mailgun.

Spoke requires the following environment variables to be set to send email:

  • EMAIL_FROM
  • EMAIL_HOST
  • EMAIL_HOST_PASSWORD
  • EMAIL_HOST_PORT
  • EMAIL_HOST_USER

Postmark

If you're using Postmark as your email provider, you will need to set EMAIL_HOST_SECURE=0. This is because Postmark supports TLS via STARTTLS, which the nodemailer library requires that you set the secure argument to false in this case.

See the environment variables reference document for more information.