Send email with MailerSend

Made by MailerSend

Send transactional emails using MailerSend.

300+
installs
Works with
Cloud Firestore
Version
0.1.8 | Source code
Tags
messaging
License
Apache-2.0
Publisher
MailerSend
Report
Bug
Abuse

How this extension works

馃挭 How it works

After its installation, this extension monitors all document writes to the EMAIL_COLLECTION collection. Email is sent based on the contents of the document鈥檚 fields. The document鈥檚 fields specify an email data.

Send an email

Here's a basic example document write that would trigger this extension
admin.firestore().collection('emails').add({
  to: [
    {
      email: 'recipient@example.com',
      name: 'Recipient name'
    }
  ],
  from: {
    email: 'from@example.com',
    name: 'From name'
  },
  cc: [
    {
      email: 'cc.recipient@example.com',
      name: 'CC recipient name'
    }
  ],
  bcc: [
    {
      email: 'bcc.recipient@example.com',
      name: 'Bcc recipient name'
    }
  ],
  subject: 'Hello from Firebase!',
  html: 'This is an <code>HTML</code> email body.',
  text: 'This is an TEXT email body.',
  template_id: 'abc123ced',
    variables: [
      {
        email: 'recipient@example.com',
        substitutions: [
          {
            var: 'variable_name',
            value: 'variable value'
          }
        ]
      }
    ],
    personalization: [
      {
        email: 'recipient@example.com',
        data: {
          personalization_name: 'personalization value'
        }
      }
    ],
    tags: ['tag1', 'tag2'],
    reply_to: {
      email: 'reply_to@example.com',
        name: 'Reply to name'
    },
    send_at: '123465789'
})

Additional setup

Before installing this extension, set up the following Firebase service in your Firebase project:

Then, in the MailerSend dashboard:

  • Add a domain and verify it editing your DNS records.
  • Create a new API token with full access.

Collection fields

Find all the JSON field parameters you can add to your API call, provided in dot notation
JSON field parameter Type Required Limitations Details
from object yes * Not required if set in extension config or template_id is present and template has default sender set.
from.email string yes * Must be a verified domain or subdomain. Not required if set in extension config or template_id is present and template has default sender set.
from.name string no from.email will be used if not provided or, if set in extension config or template_id is present with default values, the default subject from that will be used.
to object[] yes Min 1, max 50
to.*.email string yes
to.*.name string no The name of the recipient. May not contain ; or ,.
cc object[] no Max 10
cc.*.email string yes
cc.*.name string no The name of the CC recipient. May not contain ; or ,.
bcc object[] no Max 10
bcc.*.email string yes
bcc.*.name string no The name of the BCC recipient. May not contain ; or ,.
reply_to object no
reply_to.email string no Can be set in extension config
reply_to.name string no Can be set in extension config
subject string yes * Not required if template_id is present and template has default subject set.
text string yes * Max size of 2 MB. Email represented in a text (text/plain) format. * Only required if there鈥檚 no html or template_id present.
html string yes * Max size of 2 MB. Email represented in HTML (text/html) format. * Only required if there鈥檚 no text or template_id present.
template_id string yes * * Only required if there鈥檚 no text or html present.
tags string[] no Limit is max 5 tags.
variables object[] no These will be replaced in the email content using {$var} format. Can be used in the subject, html, text fields.
variables.*.email string yes Email address that substitutions will be applied to. Read more about simple personalization.
variables.*.substitutions object[] yes
variables.*.substitutions.*.var string yes Name of the variable, will replace {$var} in the subject, html, text fields.
variables.*.substitutions.*.value string yes Value to be replaced, based on the variables.*.substitutions.*.var name.
personalization object[] no Allows using personalization in {{ var }} syntax. Can be used in the subject, html, text fields. Read more about advanced personalization.
personalization.*.email string yes Email address that personalization will be applied to.
personalization.*.data object[] yes Object with key: value pairs. Values will be added to your template using {{ key }} syntax.
send_at integer no min: now, max: now + 72hours Has to be a Unix timestamp. Please note that this timestamp is a minimal guarantee and that the email could be delayed due to server load.

Email results

After email sending is triggered this extension fills results into the delivery field.

Field Description
error Validation error, or error from the server
message_id Message ID in MailerSend system
state State of an email sending: ERROR, SUCCESS

馃挸 Billing

This extension uses other Firebase or Google Cloud Platform services which may have associated charges:

  • Cloud Functions

When you use Firebase Extensions, you鈥檙e 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.

This extension also uses the following third-party services:

You are responsible for any costs associated with your use of these services.