Sendgrid-nodejs: Question: From name on v3 where and how to add.

Created on 16 Aug 2017  路  5Comments  路  Source: sendgrid/sendgrid-nodejs

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?

help wanted question

Most helpful comment

All 5 comments

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'
    },
  });
Was this page helpful?
0 / 5 - 0 ratings

Related issues

egges picture egges  路  3Comments

amlcodes picture amlcodes  路  4Comments

mikemaccana picture mikemaccana  路  4Comments

polkhovsky picture polkhovsky  路  3Comments

prasoonjalan picture prasoonjalan  路  3Comments