sendgrid-nodejs
sendgrid-nodejs copied to clipboard
Sender Name is not set when sending email via SMTP
Consider the following code:
var sendgrid = require("sendgrid")(sg_username, sg_password);
var Email = sendgrid.Email;
var email = new Email({
to: '[email protected]',
from: '[email protected]',
fromname: 'This is my name',
subject: 'Test subject',
text: 'Test text',
html: '<h1>Test HTML Body</h1>'
});
sendgrid.send(email, function(err, json) {
if (err) return console.log(err);
console.log(json);
});
This will produce correct results, and you will receive correct From email header:
From: This is my name <[email protected]>
By selecting to send email via SMTP:
var sendgrid = require("sendgrid")(sg_username, sg_password, {api: 'smtp'});
the from name is missing.
From: <[email protected]>
Looking into this. In the meantime, I recommend switching to sending via HTTP. It's actually slightly faster (because SMTP is a chatty protocol) and is just if not more reliable internally in our system.
Turns out this was also affecting toname.
Fixed and in 0.4.6