Skip to content
Branch: master
Find file History
Pull request Compare This branch is 4 commits behind next.
Salakar test(*): Introduce Jest testing
Introduce Jest testing into the project. Added tests to firestore-send-email
Latest commit 4ecd09c Oct 10, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
__tests__
functions
.gitignore
POSTINSTALL.md
PREINSTALL.md
README.md
extension.yaml
jest.config.js
jest.setup.js
jest.teardown.js
package-lock.json
package.json
tsconfig.json

README.md

firestore-send-email

VERSION: 0.1.0

DESCRIPTION: Composes and sends an email based on the contents of a document written to a specified Cloud Firestore collection.

CONFIGURATION PARAMETERS:

  • Deployment location: Where should the extension be deployed? For help selecting a location, refer to the location selection guide.

  • SMTP connection URI: A URI representing an SMTP server that this extension can use to deliver email.

  • Email documents collection: What is the path to the collection that contains the documents used to build and send the emails?

  • Default FROM address: The email address to use as the sender's address (if it's not specified in the added email document).

  • Default REPLY-TO address: The email address to use as the reply-to address (if it's not specified in the added email document).

  • Users collection: A collection of documents keyed by user UID. If the toUids, ccUids, and/or bccUids recipient options are used in the added email document, this extension delivers email to the email field based on lookups in this collection.

  • Templates collection: A collection of email templates keyed by name. This extension can render an email using a Handlebar template, if the template is specified in the added email document.

CLOUD FUNCTIONS CREATED:

  • processQueue (providers/cloud.firestore/eventTypes/document.write)

DETAILS: 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.

ACCESS REQUIRED:

This extension will operate with the following project IAM roles:

  • datastore.user (Reason: Allows this extension to access Cloud Firestore to read and process added email documents.)
You can’t perform that action at this time.