I want to add a name to my "from" field using the SendGrid API, but I do not know how to do this. I tried setting the "from" parameter in sendgrid.send
to Name <example@example.com>
but that didn't work. Thanks.

- 1,608
- 3
- 20
- 30
6 Answers
Updated example with the syntax used in the latest version of the Sendgrid Node.js library.
sendgrid.send({
to: 'you@yourdomain.com',
from: {
email: 'example@example.com',
name: 'Sender Name'
},
subject: 'Hello World',
text: 'My first email through SendGrid'
});

- 2,589
- 3
- 23
- 30
-
Thanks for that, same problem and I couldn't find the `name` field in the documentation, in-fact the docs aren't particularly easy to navigate around. – JMac Feb 02 '18 at 04:35
-
1I agree. I have issued a [pull request](https://github.com/sendgrid/sendgrid-nodejs/pull/645) trying to clarify this in the documentation somewhat, but to no avail so far. – Incinerator Feb 03 '18 at 16:38
-
Don't know if it was like this a few months ago, but this is documented in [github](https://github.com/sendgrid/sendgrid-nodejs/blob/master/packages/mail/USE_CASES.md#flexible-email-address-fields) now – Jarvis Johnson Sep 19 '18 at 20:54
-
Update: the PR mentioned above has finally been merged, almost a year later. – Incinerator Oct 30 '18 at 18:47
-
2I found the docs here https://github.com/sendgrid/sendgrid-nodejs/blob/master/use-cases/flexible-address-fields.md – ptimson Jun 17 '19 at 18:17
-
3This should be the accepted answer for the Sendgrid API V3 – Trev14 Sep 20 '19 at 14:15
-
1This works. The accepted answer no longer works. – Or Assayag Dec 05 '20 at 17:18
-
I think you need to set up a verified single sender for this to work. https://app.sendgrid.com/settings/sender_auth/senders – MadMac Mar 30 '21 at 22:31
You can set the from parameter in a couple of ways:
var SendGrid = require('sendgrid').SendGrid;
var sendgrid = new SendGrid(user, key);
sendgrid.send({
to: 'you@yourdomain.com',
from: 'example@example.com', // Note that we set the `from` parameter here
fromname: 'Name', // We set the `fromname` parameter here
subject: 'Hello World',
text: 'My first email through SendGrid'
}, function(success, message) {
if (!success) {
console.log(message);
}
});
or you can create an Email
object and fill in the stuff on that:
var Email = require('sendgrid').Email;
var email = new Email({
to: 'you@yourdomain.com',
from: 'example@example.com',
fromname: 'Name',
subject: 'What was Wenger thinking sending Walcott on that early?',
text: 'Did you see that ludicrous display last night?'
});
sendgrid.send(email, function() {
// ...
});
You might want to take a few minutes and go over the README document on the Github page. It has pretty detailed info on how to use the library and the various features it offers.

- 13,118
- 5
- 56
- 80
-
1Thanks. I read that README and for some reason, I didn't see the `fromname` field in the docs while trying to find something about it. Next time I'll try Ctrl+F :) – Ian Macalinao May 26 '13 at 19:49
-
what is user and key. I am thinking that is key is api key but what is user? that is username or any other – suresh pareek Nov 24 '16 at 10:47
-
13
-
3This doesn't work anymore. Look https://stackoverflow.com/a/47903145/2803872 answer. – vohrahul Jan 14 '19 at 08:32
-
@Swift this doesn't work anymore. Can you please mention this in your answer? – secretshardul Oct 18 '20 at 09:56
-
here is the use case page in github https://github.com/sendgrid/sendgrid-nodejs/blob/main/docs/use-cases/README.md#email-use-cases – maxi-code Dec 23 '22 at 18:21
Although the updated use cases don't include the from
key
https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/flexible-address-fields.md
This one worked for me
to: 'user@userdomain.com',
from: {
name: 'Sender'
email: 'me@mydomain.com',
},
subject: 'Hello World',
html: `<html><p>Hello World</p></html>`
});

- 416
- 5
- 10
If you are using the nodejs Helper library, use the following arguments:
from_email = new helper.Email("email@domain.com", "Email Name");

- 776
- 1
- 8
- 17
from github on the node library you can use either of the methods below to have a send from email and name
from: {
name: 'Name Here',
email: 'email here'
}
or
from: "Cool Name <some@email.com>"

- 1,717
- 2
- 23
- 32
For strapijs users, in plugins you can change like below
module.exports = ({ env }) => ({
// ...
email: {
config: {
provider: 'sendgrid',
providerOptions: {
apiKey: env('SENDGRID_API_KEY'),
},
settings: {
defaultFrom: 'The Name You Want <myemail@protonmail.com>',
defaultReplyTo: 'The Name You Want <myemail@protonmail.com>',
},
},
},
// ...
});

- 51
- 1
- 9