Is there anyway to send email to a list of contact? I can't find any api docs about this.
When sending an email with SendGrid you can send to one or multiple email addresses, and you can do so via the to
, cc
, and/or bcc
fields.
When you send an email via SendGrid, you do so using "personalizations". According to the documentation, personalizations are:
An array of messages and their metadata. Each object within personalizations can be thought of as an envelope - it defines who should receive an individual message and how that message should be handled.
An example of an array of personalizations might look like this:
[
{
to: [
{
email: 'john_doe@example.com',
name: 'John Doe'
},
{
email: 'julia_doe@example.com',
name: 'Julia Doe'
}
],
cc: [
{
email: 'jane_doe@example.com',
name: 'Jane Doe'
}
],
bcc: [
{
email: 'james_doe@example.com',
name: 'Jim Doe'
}
]
},
{
from: {
email: 'sales@example.com',
name: 'Example Sales Team'
},
to: [
{
email: 'janice_doe@example.com',
name: 'Janice Doe'
}
],
bcc: [
{
email: 'jordan_doe@example.com',
name: 'Jordan Doe'
}
]
}
]
In the above example, one email is sent to two different people, John Doe and Julia Doe, cc'd to Jane Doe and bcc'd to Jim Doe. An email with the same content is also sent from a different email address (sales@example.com) to Janice Doe and bcc'd to Jordan Doe.
Hopefully you can see that specifying the recipients of an email is very flexible and you can send to many people at the same time.
Check out the documentation and code examples for sending emails with SendGrid for more information.