
Trigger Email
Composes and sends an email based on the contents of a document written to a specified Cloud Firestore collection.
How this extension works
Use this extension to render and send emails that contain the information from documents added to a specified Cloud Firestore collection.
Adding a document triggers this extension to send an email built from the document's fields. The document's top-level fields specify the email sender and recipients, including to
, cc
, and bcc
options (each supporting UIDs). The document's message
field specifies the other email elements, like subject line and email body (either plaintext or HTML)
Here's a basic example document write that would trigger this extension:
admin.firestore().collection('mail').add({ to: 'someone@example.com', message: { subject: 'Hello from Firebase!', html: 'This is an <code>HTML</code> email body.', }, })
You can also optionally configure this extension to render emails using Handlebar templates. Each template is a document stored in a Cloud Firestore collection.
When you configure this extension, you'll need to supply your SMTP credentials for mail delivery.
Additional setup
Before installing this extension, make sure that you've set up a Cloud Firestore database in your Firebase project.
Billing
This extension uses other Firebase or Google Cloud Platform services which may have associated charges:
- Cloud Firestore
- Cloud Functions
When you use Firebase Extensions, you're only charged for the underlying resources that you use. A paid-tier billing plan is only required if the extension uses a service that requires a paid-tier plan, for example calling to a Google Cloud Platform API or making outbound network requests to non-Google services. All Firebase services offer a free tier of usage. Learn more about Firebase billing.
Usage of this extension also requires you to have SMTP credentials for mail delivery. You are responsible for any associated costs with your usage of your SMTP provider.
How to install this extension
Using the Firebase console
To install and manage extensions, you can use the Firebase console.
Install using consoleUsing the Firebase CLI
To install and manage extensions, you can also use the Firebase CLI:
Step 1: Run the following npm command to install the CLI or update to the latest CLI version.
npm install -g firebase-toolsDoesn't work? Take a look at the Firebase CLI reference or change your npm permissions.
Step 2: Install this extension by running the following command
firebase ext:install firestore-send-email --project=projectId_or_alias