Skip to content

fix(firestore-send-email) restore headers support #2440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions firestore-send-email/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Version 0.2.4

fix: add missing 'headers' field to the mailOptions interface

docs: update documentation to include 'headers' field

## Version 0.2.3

fix: remove strict validation of email "from" field
Expand Down
23 changes: 23 additions & 0 deletions firestore-send-email/PREINSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,29 @@ You can also optionally configure this extension to render emails using [Handleb

When you configure this extension, you'll need to supply your **SMTP credentials for mail delivery**. Note that this extension is for use with bulk email service providers, like SendGrid, Mailgun, etc.

#### Using custom headers

You can add custom headers to your emails by including a `headers` field in the document you add to the Firestore collection. The `headers` field should be an object where each key is the header name and the value is the header value.

## Example JSON with Custom Headers:
```json
{
"to": ["[email protected]"],
"message": {
"subject": "Test Email with Custom Headers",
"text": "This is a test email to see if custom headers work.",
"html": "<strong>This is a test email to see if custom headers work.</strong>"
},
"headers": {
"X-Custom-Header": "CustomValue",
"X-Another-Header": "AnotherValue",
}
}
```

Add this document to the Firestore mail collection to send an email with custom headers.
You can even include headers like 'List-Unsubscribe' to allow recipients to unsubscribe from your emails.

#### Firestore-Send-Email: SendGrid Categories

When using SendGrid (`SMTP_CONNECTION_URI` includes `sendgrid.net`), you can assign categories to your emails.
Expand Down
23 changes: 23 additions & 0 deletions firestore-send-email/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,29 @@ You can also optionally configure this extension to render emails using [Handleb

When you configure this extension, you'll need to supply your **SMTP credentials for mail delivery**. Note that this extension is for use with bulk email service providers, like SendGrid, Mailgun, etc.

#### Using custom headers

You can add custom headers to your emails by including a `headers` field in the document you add to the Firestore collection. The `headers` field should be an object where each key is the header name and the value is the header value.

## Example JSON with Custom Headers:
```json
{
"to": ["[email protected]"],
"message": {
"subject": "Test Email with Custom Headers",
"text": "This is a test email to see if custom headers work.",
"html": "<strong>This is a test email to see if custom headers work.</strong>"
},
"headers": {
"X-Custom-Header": "CustomValue",
"X-Another-Header": "AnotherValue",
}
}
```

Add this document to the Firestore mail collection to send an email with custom headers.
You can even include headers like 'List-Unsubscribe' to allow recipients to unsubscribe from your emails.

#### Firestore-Send-Email: SendGrid Categories

When using SendGrid (`SMTP_CONNECTION_URI` includes `sendgrid.net`), you can assign categories to your emails.
Expand Down
2 changes: 1 addition & 1 deletion firestore-send-email/extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

name: firestore-send-email
version: 0.2.3
version: 0.2.4
specVersion: v1beta

displayName: Trigger Email from Firestore
Expand Down
1 change: 1 addition & 0 deletions firestore-send-email/functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ async function deliver(ref: DocumentReference): Promise<void> {
subject: payload.message?.subject,
text: payload.message?.text,
html: payload.message?.html,
headers: payload?.headers,
attachments: payload.message?.attachments,
categories: payload.categories,
templateId: payload.sendGrid?.templateId,
Expand Down