Sendgrid-nodejs: To field only accepts plain email

Created on 13 Mar 2019  ·  3Comments  ·  Source: sendgrid/sendgrid-nodejs

Issue Summary

When using '@sendgrid/mail' to send any email, the 'to' field only accepts plain email addresses, not name/email format (example: {name:'John Doe', email:'[email protected]'} ).

Steps to Reproduce

const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const msg = {
  to: { email:'[email protected]', name: 'John Doe' },
  from: '[email protected]',
  subject: 'Sending with SendGrid is Fun',
  text: 'and easy to do anywhere, even with Node.js',
  html: '<strong>and easy to do anywhere, even with Node.js</strong>',
};
sgMail.send(msg);

Technical details:

  • sendgrid-nodejs Version: master (latest commit: [commit number])
  • Node.js Version: 4.1.2
unknown or a waiting for feedback question

All 3 comments

Hello @agostonbonomi,

Here are the supported methods of formatting email.

Please let me know if that helps.

Thanks!

With Best Regards,

Elmer

hey @thinkingserious , thanks for this. i missed this in the docs, works fine :)

Thank for the follow up @agostonbonomi!

Was this page helpful?
0 / 5 - 0 ratings