Twilio SendGrid | SendGrid Docs

Build transactional and marketing email solutions with Twilio SendGrid.

Take the next steps with Twilio SendGrid

Your app

const sgMail = require('@sendgrid/mail');

sgMail.setApiKey(process.env.SENDGRID_API_KEY);

const msg = {

to: 'recipient@example.com',

from: 'sender@example.com',

subject: 'Ahoy!',

html: 'Ahoy, World!',

};

sgMail

.send(msg)

.then((error) => console.error(error));

Take the next steps with Twilio SendGrid


Send your first email

Get started with the Twilio SendGrid Mail Send API and the open-source SDKs. To send your first message, use the following sample code in your preferred programming language.

C#GoJavaNode.jsPHPPythonRuby

2

using System.Threading.Tasks;

4

using SendGrid.Helpers.Mail;

10

var apiKey = Environment.GetEnvironmentVariable("SENDGRID_API_KEY");

11

var client = new SendGridClient(apiKey);

12

var from = new EmailAddress("test@example.com", "Example User");

13

var subject = "Sending with Twilio SendGrid is Fun";

14

var to = new EmailAddress("test@example.com", "Example User");

15

var plainTextContent = "and easy to do anywhere, even with C#";

16

var htmlContent = "<strong>and easy to do anywhere, even with C#</strong>";

17

var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);

18

var response = await client.SendEmailAsync(msg).ConfigureAwait(false);

Email API quickstarts

To implement the previous code sample in your preferred programming language, jump to a quickstart for a full guide.


Do more with email

Twilio SendGrid offers tools that build your email communications program. Gather data from and report on the effectiveness of your email campaigns. Add content and accept files through inbound email. Use Twilio SendGrid to send and receive email or integrate with a cloud partner for email processing.


Get started with Marketing Campaigns

Create well-designed, personalized messages for your Marketing Campaigns.


Build your customer engagement infrastructure that fits the unique requirements of your business with the other communication channels from Twilio.

Messaging

Send and receive Short Message Service (SMS), Multimedia Messaging Service (MMS), Rich Communication Services (RCS), or WhatsApp messages with Twilio Programmable Messaging.

Product documentation
Flex

Build your digital engagement center for sales and customer support teams with Twilio Flex.

Product documentation