Skip to content

Email Automation

Chris Clarke edited this page Feb 25, 2020 · 1 revision

There are currently 2 systems in place for email automation

1. Firebase Auth

This has it's own system to send auth-related emails such as password reset and confirmation links. Templates can be configured from the firebase console and hooked into using the firebase auth sdk within the platform

2. Firebase Extensions

A more flexible option uses the quick-deploy Trigger Email email extension provided by firebase https://firebase.google.com/products/extensions/firestore-send-email

In order to use the extension can be enabled from the Extensions page in the console, and configured to work with a smtp mailing client such as sendinblue, mailgun, mailgrid etc. It can also be configured to work with a regular gmail account (or google hosted account on custom domain) by providing config:

and then a enabling "Less secure app access" for the google account https://myaccount.google.com/u/2/lesssecureapps

Sending Emails

Emails are sent by pushing new documents to the firestore database, as defined during setup. By default this would be adding a new doc to the mail collection, formatted as

to: ['[email protected]'],
message: {
  subject: 'Hello from Firebase!',
  text: 'This is the plaintext section of the email body.',
  html: 'This is the <code>HTML</code> section of the email body.',
}

NOTE
In the future it is likely that option 1. will be removed and integrated into an independent system based on nodemailer or similar, and with a similar workflow as option 2.