I'm trying to add thefromname on my object but I'm not sure if is the right way I'm doing.
sg.emptyRequest({
method: 'POST',
path: '/v3/mail/send',
body: {
personalizations: [
{
to: emailTo,
fromname: 'Namehere', // <== I've try fromName as well
},
],
fromname: 'Namehere', // <== I've try fromName as well
from: {email: '[email protected]'},
content: [{
type: 'text/html',
value: '<p></p>',
}],
template_id: 'id_here'
},
});
I do get the email but not with the fromname, any idea why or where I add the fromname field?
Here are some examples:
https://github.com/sendgrid/sendgrid-nodejs/blob/master/examples/mail/mail.js#L73
https://github.com/sendgrid/sendgrid-nodejs/blob/master/examples/helpers/mail/example.js#L19
Basically, from: {email: '[email protected]'} becomes from: {email: '[email protected]', name:'Namehere'}
Hi @thinkingserious, thanks a lot!
The example links are dead, @thinkingserious can you update them? I'm struggling with the same thing.
HI @astromme,
If you are using the latest version of the SDK, any of the following should work:
Name <[email protected]>
{name: 'Name', email: '[email protected]'}
With Best Regards,
Elmer
Hey just a heads up - the from object is outside of personalizations, not inside due to deliverability issues of sending from domains that don't match your whitelabeled domain or DKIM/SPF settings.
The original block above would be more like this in v3/mail/send:
sg.emptyRequest({
method: 'POST',
path: '/v3/mail/send',
body: {
personalizations: [
{
to: emailTo,
fromname: 'Namehere', // <== I've try fromName as well
},
],
content: [{
type: 'text/html',
value: '<p></p>',
}],
template_id: 'id_here'
},
from: {
email: '[email protected]',
name: 'Namehere'
},
});
Most helpful comment
Here are some examples:
https://github.com/sendgrid/sendgrid-nodejs/blob/master/examples/mail/mail.js#L73
https://github.com/sendgrid/sendgrid-nodejs/blob/master/examples/helpers/mail/example.js#L19
Basically,
from: {email: '[email protected]'}becomesfrom: {email: '[email protected]', name:'Namehere'}