Skip to content

Commit 99a4126

Browse files
Nushiocabljac
authored andcommitted
fix(firestore-send-email) restore headers support (#2463)
Originally contributed by Juan Rodriguez (Nushio) but incorrectly attributed during merge. Re-applying with proper attribution.
1 parent c13b931 commit 99a4126

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

firestore-send-email/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Version 0.2.4
22

3+
fix: add missing 'headers' field to the mailOptions interface (contributed by @Nushio)
4+
5+
docs: update documentation to include 'headers' field (contributed by @Nushio)
6+
37
fix: TTL expire type "week" fixed (#2455)
48

59
## Version 0.2.3

firestore-send-email/PREINSTALL.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,29 @@ You can also optionally configure this extension to render emails using [Handleb
1818

1919
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.
2020

21+
#### Using custom headers
22+
23+
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.
24+
25+
## Example JSON with Custom Headers:
26+
```json
27+
{
28+
"to": ["[email protected]"],
29+
"message": {
30+
"subject": "Test Email with Custom Headers",
31+
"text": "This is a test email to see if custom headers work.",
32+
"html": "<strong>This is a test email to see if custom headers work.</strong>"
33+
},
34+
"headers": {
35+
"X-Custom-Header": "CustomValue",
36+
"X-Another-Header": "AnotherValue",
37+
}
38+
}
39+
```
40+
41+
Add this document to the Firestore mail collection to send an email with custom headers.
42+
You can even include headers like 'List-Unsubscribe' to allow recipients to unsubscribe from your emails.
43+
2144
#### Firestore-Send-Email: SendGrid Categories
2245

2346
When using SendGrid (`SMTP_CONNECTION_URI` includes `sendgrid.net`), you can assign categories to your emails.

firestore-send-email/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,29 @@ You can also optionally configure this extension to render emails using [Handleb
2626

2727
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.
2828

29+
#### Using custom headers
30+
31+
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.
32+
33+
## Example JSON with Custom Headers:
34+
```json
35+
{
36+
"to": ["[email protected]"],
37+
"message": {
38+
"subject": "Test Email with Custom Headers",
39+
"text": "This is a test email to see if custom headers work.",
40+
"html": "<strong>This is a test email to see if custom headers work.</strong>"
41+
},
42+
"headers": {
43+
"X-Custom-Header": "CustomValue",
44+
"X-Another-Header": "AnotherValue",
45+
}
46+
}
47+
```
48+
49+
Add this document to the Firestore mail collection to send an email with custom headers.
50+
You can even include headers like 'List-Unsubscribe' to allow recipients to unsubscribe from your emails.
51+
2952
#### Firestore-Send-Email: SendGrid Categories
3053

3154
When using SendGrid (`SMTP_CONNECTION_URI` includes `sendgrid.net`), you can assign categories to your emails.

firestore-send-email/functions/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ async function deliver(ref: DocumentReference): Promise<void> {
173173
subject: payload.message?.subject,
174174
text: payload.message?.text,
175175
html: payload.message?.html,
176+
headers: payload?.headers,
176177
attachments: payload.message?.attachments,
177178
categories: payload.categories,
178179
templateId: payload.sendGrid?.templateId,

0 commit comments

Comments
 (0)