Send email with MailerSend
Made by MailerSend
Send transactional emails using MailerSend.
- Works with
- Cloud Firestore
- Version
- 0.3.0 | Source code
- Tags
- messaging
- License
- Apache-2.0
- Publisher
- MailerSend
- Report
- Bug
- Abuse
No publisher authored function kit replacement for this extension is available. If you want to be able to update this extension after the shutdown on March 31st we recommend you follow our guide for forking the extension and maintaining it yourself as a function kit
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’s fields. The document’s 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:
- Cloud Firestore collection in your Firebase project.
Then, in the MailerSend dashboard:
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’s 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’s no text or template_id present. |
template_id |
string |
yes * | * Only required if there’s 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’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.
This extension also uses the following third-party services:
- MailerSend (pricing information)
You are responsible for any costs associated with your use of these services.