Email

Enable Email to send and receive emails through a custom domain.

There are two parts:

  1. Your webapp emails users from a custom domain e.g. no-reply@demo.devlaunchp.ad. This is used for sending user sign up emails, welcome emails, or any other transactional emails.
  2. Users send emails to a custom domain, which are forwarded to your personal email address e.g. john.doe@nowhere.example.

To enable email, you must have already setup your custom domain.

Before you start

AWS requires a custom email domain to be verified before you can send emails.

The AWS email service, SES, is by default in sandbox mode. In sandbox mode, you can only send emails to email addresses you own.

To get out of sandbox mode so your webapp can email anyone on the internet, follow these verification steps.

  1. Ensure you already setup your Custom domain.
  2. Go to Get set up in the AWS Console.
  3. Follow the instructions under Request production access, making sure to select Transactional emails.

You can expect a response from AWS within 24 hours. Once your request is accepted, move onto the next step.

Configuration

Once your AWS account is out of sandbox mode, enable Email by configuring deployment-params.yml.

  • EmailEnabled: set to true
  • ForwardingEmailAddress: emails sent to support@yourdomain.com will be forwarded to this address.
deployment-params.yml
EmailEnabled: true
ForwardingEmailAddress: 'john.doe@nowhere.example'

Deployment

Run npm run deploy.

DevLaunchPad automatically detects the new email settings and configures:

  • Sign up emails to send from no-reply@yourdomain.com instead of no-reply@verificationemail.com (if you've enabled the Sign in feature).
  • Welcome emails to send to all users after purchase.
  • A pro@yourdomain.com account for testing.
  • Email forwarding from support@yourdomain.com to the configured ForwardingEmailAddress.

Customising emails

Emails are defined in serverless/resources/emails in Markdown format.

By default, DevLaunchPad ships with two emails.

  1. new-user.md sent when a new user is created after purchase (Sign In feature enabled).
  2. welcome.md sent after purchase (Sign In feature disabled).

You can customise these emails, using variables:

  • friendlyName - corresponds to SiteName in deployment-params.yml.
  • siteBaseURL - corresponds to your website URL e.g. https://demo.devlaunchp.ad.

Here's an example welcome email.

Welcome to {{friendlyName}}!

Head over to [the website]({{siteBaseURL}}) when you're ready.

Speak soon,

{{friendlyName}}

Advanced usage

You can send an email from your application any time, using the sendEmail lambda function defined in serverless.yml.

Execute the lambda function with a JSON body containing these parameters:

  • emailName - the simple name of the Markdown file (without extension) defined in serverless/resources/emails e.g. welcome.
  • subject - the subject line of the email.
  • toAddress - the email recipient.

Here's an example body:

{
    "emailName": "report",
    "subject": "Your PDF report",
    "toAddress": "john.doe@nowhere.example"
}

Custom substitutions

Use any key/value pair in your email Markdown by passing a customSubstitutions object in the JSON body.

For example:

{
    "emailName": "report",
    "subject": "Your PDF report",
    "toAddress": "john.doe@nowhere.example",
    "customSubstitutions": {
        "city": "London"
    }
}

Your markdown can now reference the city value using {{city}} syntax.