sendgrid-nodejs
sendgrid-nodejs copied to clipboard
To field only accepts plain email
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
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!