Home > Back-end >  How do i add a sender name on send grid
How do i add a sender name on send grid

Time:04-10

The code below is my sendgrid helper function presently, this is what comes up as the sender name "info" which is conned from infogmail.com. . i would like to add a custom name. i have read the docs but i have not seen a solution to my problem. all the solutions i saw was for python

  const msg = {
    to: email,
    from: `${SENDER_EMAIL}`,
    fromname: FROM_NAME,
    subject: "Thanks for the Gift",
    html: `${html(name, SENDER_EMAIL, SENDER_NAME)}`,
  };

  sgMail
    .send(msg)
    .then(() => {
      console.log("Email sent");
    })
    .catch((error) => {
      console.error(error);
    });
};```

CodePudding user response:

You can in this way:

sendgrid.send({
  to: '[email protected]',
  from: {
      email: '[email protected]',
      name: 'Sender Name'
  },
  subject: 'Hello World',
  text: 'My first email through SendGrid'
});
  • Related