Skip to content
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

🐛 Bug Report: Missing additional fields in Custom SMTP provider #5689

Closed
2 tasks done
frisket opened this issue Jun 6, 2024 · 1 comment
Closed
2 tasks done

🐛 Bug Report: Missing additional fields in Custom SMTP provider #5689

frisket opened this issue Jun 6, 2024 · 1 comment
Labels

Comments

@frisket
Copy link

frisket commented Jun 6, 2024

📜 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):

{
   "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>;.

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?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to submit PR?

Yes I am willing to submit a PR!

Copy link

linear bot commented Jun 6, 2024

@github-actions github-actions bot added the triage label Jun 6, 2024
@linear linear bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant