Sendgrid-nodejs: Reply To

Created on 29 Nov 2017  路  5Comments  路  Source: sendgrid/sendgrid-nodejs

I can't find a single example of how to customize a Reply-To header with this library. Can you please point me in the right direction?

Currently trying something like this...

  let mail = new helper.Mail(
      new helper.Email(this.from),
      this.subject,
      new helper.Email(this.to),
      new helper.Content('text/html', this.content),
      new helper.Header('Reply-To', this.to)
    );
help wanted question

Most helpful comment

Thanks @thinkingserious !

I actually just got it solved using the mail helper as follows...

let mail = new helper.Mail(
      new helper.Email(this.from),
      this.subject,
      new helper.Email(this.to),
      new helper.Content('text/html', this.content)
    );
    mail.setReplyTo(new helper.Email(this.to));

Works for me!

All 5 comments

I think I'm getting closer...
I tried this:

mail.personalizations[0].addHeader(new helper.Header('Reply-To', this.to));

Then got an error:

                {
                    "message": "Header can not be one of the reserved keys. Refer to documentation link.",
                    "field": "personalizations.0.headers.Reply-To",
                    "help": "http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.personalizations.headers"
                }

Unfortunately there was nothing very helpful in the documentation it pointed me to.

Hi @ericuldall,

Here is an example with reply to. Please let me know if that works for you. Thanks!

With Best Regards,

Elmer

Thanks @thinkingserious !

I actually just got it solved using the mail helper as follows...

let mail = new helper.Mail(
      new helper.Email(this.from),
      this.subject,
      new helper.Email(this.to),
      new helper.Content('text/html', this.content)
    );
    mail.setReplyTo(new helper.Email(this.to));

Works for me!

Awesome! Thanks for the follow up!

https://github.com/sendgrid/sendgrid-nodejs/blob/main/docs/use-cases/cc-bcc-reply-to.md

You can specify the cc, bcc, and replyTo fields for more control over who you send the email to and where people will reply to:

const msg = {
  to: '[email protected]',
  cc: '[email protected]',
  bcc: ['[email protected]', '[email protected]'],
  from: '[email protected]',
  replyTo: '[email protected]',
  subject: 'Hello world',
  text: 'Hello plain world!',
  html: '<p>Hello HTML world!</p>',
};
Was this page helpful?
0 / 5 - 0 ratings

Related issues

nicoasp picture nicoasp  路  3Comments

egges picture egges  路  3Comments

wooyah picture wooyah  路  4Comments

thinkingserious picture thinkingserious  路  4Comments

agostonbonomi picture agostonbonomi  路  3Comments