You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a need to set some of the more advanced properties when sending emails using the Custom SMTP provider (nodemailer).
In particular, I need to add custom headers and also to control the envelope sender/from address to ensure proper bounce/reply-to handling.
For example, I need to be able to do this (sample event trigger payload):
{
"name": "email-workflow",
"to": {
"subscriberId": "1234",
"firstName": "User",
"lastName": "One",
"email": "[email protected]"
},
"payload": {
"email_body": "<b>This is the body of the email</b>",
"email_subject": "This is a test"
},
"overrides": {
"email": {
"headers": { <---- NEW
"X-Custom-Header": "123456789"
},
"envelope": { <--- NEW
"from": "[email protected]
},
"senderName": "Sender User",
"replyTo": "[email protected]",
"html": "<h1>This should be the HTML part of the email</h1>",
"text": "This should be in plain text in the email",
"layoutIdentifier": "empty"
}
}
}
Looking through the code (packages/providers/src/lib/nodemailer/nodemailer.provider.ts) , it appears that this is already partially handled as the IEmailOptions interface has support for replyTo and headers. It just needs to be passed through to the nodemailer in the Custom STMP provider.
It appears that the headers are already handled in other providers, eg: sendgrid, so it should be a simple copy/paste from there, I think, like:
private createMailData(options: IEmailOptions): SendMailOptions {
const sendMailOptions: SendMailOptions = {
....
to: options.to,
subject: options.subject,
headers: options.headers <-- new
envelope: options.envelope <-- new
};
if (options.replyTo) {
sendMailOptions.replyTo = options.replyTo;
}
return sendMailOptions;
}
Adding support for the envelope options would require extending IEmailOptions with additional fields, similar to the header using something like envelope?: Record<string, string>;.
📜 Description
I have a need to set some of the more advanced properties when sending emails using the Custom SMTP provider (nodemailer).
In particular, I need to add custom headers and also to control the envelope sender/from address to ensure proper bounce/reply-to handling.
For example, I need to be able to do this (sample event trigger payload):
Looking through the code (
packages/providers/src/lib/nodemailer/nodemailer.provider.ts
) , it appears that this is already partially handled as theIEmailOptions
interface has support forreplyTo
andheaders
. It just needs to be passed through to the nodemailer in the Custom STMP provider.It appears that the headers are already handled in other providers, eg: sendgrid, so it should be a simple copy/paste from there, I think, like:
Adding support for the envelope options would require extending IEmailOptions with additional fields, similar to the header using something like
envelope?: Record<string, string>;
.nodemailer supports envelope options here: https://nodemailer.com/message/#routing-options and https://nodemailer.com/smtp/envelope/
👟 Reproduction steps
N/A
👍 Expected behavior
Custom fields/headers should be passed through to the SMTP server
👎 Actual Behavior with Screenshots
Desired fields/headers are not passed through to the mail server
Novu version
0.24.0 (docker)
npm version
No response
node version
No response
📃 Provide any additional context for the Bug.
Seems a similar request was made here: #1949
👀 Have you spent some time to check if this bug has been raised before?
🏢 Have you read the Contributing Guidelines?
Are you willing to submit PR?
Yes I am willing to submit a PR!
The text was updated successfully, but these errors were encountered: