Email Api

curl –request POST \
–url \
–header “Authorization: Bearer $SENDGRID_API_KEY” \
–header ‘Content-Type: application/json’ \
–data ‘{“personalizations”: [{“to”: [{“email”: “”}]}],”from”: {“email”: “”},”subject”: “Sending with SendGrid is Fun”,”content”: [{“type”: “text/plain”, “value”: “and easy to do anywhere, even with cURL”}]}’
view raw gistfile1.txt hosted with ❤ by GitHub
// using Twilio SendGrid’s v3 Node.js Library
const sgMail = require(@sendgrid/mail);
const msg = {
subject: Sending with Twilio SendGrid is Fun,
text: and easy to do anywhere, even with Node.js,
html: <strong>and easy to do anywhere, even with Node.js</strong>,
view raw v3-hello-email.js hosted with ❤ by GitHub
# using SendGrid’s Ruby Library
require sendgrid-ruby
include SendGrid
from =
to =
subject = Sending with SendGrid is Fun
content = text/plain, value: and easy to do anywhere, even with Ruby)
mail =, subject, to, content)
response = sg.client.mail._(send).post(request_body: mail.to_json)
puts response.status_code
puts response.body
puts response.headers
view raw v3-hello-email.rb hosted with ❤ by GitHub
# using SendGrid’s Python Library
import os
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail
message = Mail(,,
subject=Sending with Twilio SendGrid is Fun,
html_content=<strong>and easy to do anywhere, even with Python</strong>)
sg = SendGridAPIClient(os.environ.get(SENDGRID_API_KEY))
response = sg.send(message)
except Exception as e:
view raw hosted with ❤ by GitHub
// using SendGrid’s Go Library
package main
import (
func main() {
from := mail.NewEmail(Example User,
subject := Sending with SendGrid is Fun
to := mail.NewEmail(Example User,
plainTextContent := and easy to do anywhere, even with Go
htmlContent := <strong>and easy to do anywhere, even with Go</strong>
message := mail.NewSingleEmail(from, subject, to, plainTextContent, htmlContent)
client := sendgrid.NewSendClient(os.Getenv(SENDGRID_API_KEY))
response, err := client.Send(message)
if err != nil {
} else {
view raw v3-hello-email.go hosted with ❤ by GitHub
require vendor/autoload.php; // If you’re using Composer (recommended)
// Comment out the above line if not using Composer
// require(“<PATH TO>/sendgrid-php.php”);
// If not using Composer, uncomment the above line and
// download from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
$email = new \SendGrid\Mail\Mail();
$email->setFrom(, Example User);
$email->setSubject(Sending with SendGrid is Fun);
$email->addTo(, Example User);
$email->addContent(text/plain, and easy to do anywhere, even with PHP);
text/html, <strong>and easy to do anywhere, even with PHP</strong>
$sendgrid = new \SendGrid(getenv(SENDGRID_API_KEY));
try {
$response = $sendgrid->send($email);
print $response->statusCode() . \n;
print $response->body() . \n;
} catch (Exception $e) {
echo Caught exception: . $e->getMessage() .\n;
view raw v3-hello-email.php hosted with ❤ by GitHub
// using SendGrid’s Java Library
import com.sendgrid.*;
public class Example {
public static void main(String[] args) throws IOException {
Email from = new Email(;
String subject = Sending with SendGrid is Fun;
Email to = new Email(;
Content content = new Content(text/plain, and easy to do anywhere, even with Java);
Mail mail = new Mail(from, subject, to, content);
SendGrid sg = new SendGrid(System.getenv(SENDGRID_API_KEY));
Request request = new Request();
try {
Response response = sg.api(request);
} catch (IOException ex) {
throw ex;
view raw hosted with ❤ by GitHub
// using SendGrid’s C# Library
using SendGrid;
using SendGrid.Helpers.Mail;
using System;
using System.Threading.Tasks;
namespace Example
internal class Example
private static void Main()
static async Task Execute()
var apiKey = Environment.GetEnvironmentVariable(NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY);
var client = new SendGridClient(apiKey);
var from = new EmailAddress(, Example User);
var subject = Sending with SendGrid is Fun;
var to = new EmailAddress(, Example User);
var plainTextContent = and easy to do anywhere, even with C#;
var htmlContent = <strong>and easy to do anywhere, even with C#</strong>;
var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
var response = await client.SendEmailAsync(msg);
view raw v3-hello-email.cs hosted with ❤ by GitHub

Integrate and Deliver via SMTP or API in 5 Minutes or Less

Our SMTP relay setup and flexible Web and SMTP APIs provide a customizable integration approach for your transactional email.

  • Integrate with support from multiple development frameworks and client libraries, including Node.js, Ruby, Python, Go, PHP, Java, and C#.
  • Get answers when you need them through our robust documentation, support, video tutorials, and online community.
  • Access account statistics and engagement data in real-time through our Event Webhook.

Optimize Your Inbox Delivery and Engagement

Email delivery is our passion. Our industry-leading email delivery platform includes tools and expertise to make sure your emails get to the inbox and drive engagement.

  • Improve deliverability with domain and link customization, whether sending from shared IP pools or a dedicated IP.
  • Eliminate domain spoofing and phishing emails with our custom SPF and DKIM record creation.
  • Have your email monitored and managed by our 30+ member team of deliverability experts.
  • Maximize your email engagement to your mobile app experience with our universal linking functionality.

Learn Why We’re the Delivery Experts

Secure Your Sending Environment

You trust your data to us and we take that very seriously. We have a number of measures in place to keep that trust.

  • Secure your email with two-factor authentication, precise teammate permissions, API key permissions, IP Access Management, and more.
  • Safeguard your messages with enforced or opportunistic TLS.
  • Benefit from continuous mail flow through our secure, distributed, and redundant data centers.

Expedite Your Integration With Robust Documentation

Integrate and easily send email from your app, whether it’s a CMS, framework, CRM, or your own code.

  • Try it out, integrate, send, and track your emails with help from our interactive online documentation.
  • Get started quickly with our code examples and helper functions available in a variety of languages, including: Python, PHP, Go Lang, Java, Node.js, Ruby, and C#.

Share a Single Email Platform With Your Whole Team

SendGrid powers email delivery for your entire team, providing one platform for all your email sending needs.

  • Enjoy secure account sharing by specifying access levels for your developers, marketers, accountants, and designers.
  • Consume recipient engagement data with our powerful dashboard that is easily accessible for non-technical users.
  • Streamline your template creation workflows with our marketing and transactional email template tools.

Gain Peace of Mind With Email Sending Visibility

Troubleshooting occasional email delivery issues is unavoidable. To help, we provide added visibility into each of your email messages with our enhanced email activity feed.

  • Easily pinpoint a specific email message with our email activity feed’s advanced search and multiple filter capabilities—including partial subject
    line search.
  • Understand the entire journey of that message with sequential event organization —detailed from processed to delivered, through to opened
    and clicked.
  • Harness the freedom to access the email activity data you need when you need it, with the additional email activity history option* (up to 30 days visible in the UI), exportable CSV, and details-by-email API.
  • *Please note some limitations apply. Email volumes over 100 million are not included. An additional purchase is required for additional email history up to 30 days as well as new events API endpoints.

What Our Customers are Saying

Integration took 3 lines of code and about 30 seconds.

Bart Lorang
CEO and Co-founder

SendGrid was the only provider that had the email tools, expertise, and platform flexibility to let us put transactional email infrastructure on autopilot.

Oliver Hurst-Hiller
CTO and Head of Product

SendGrid has been instrumental in scaling our email without interruptions. I’m used to working on imperfect systems, so it’s nice to have things just work for me.

Alex Karweit
Engineering Lead

Over 80,000 paying customers trust SendGrid to send more than 50 billion emails every month.

The SendGrid Difference

Proven Deliverability

We offer domain authentication, compliance and deliverability coaching, and proactive ISP outreach to ensure you achieve optimal inbox delivery.

Scale With Confidence

Whether you’re a startup or a large enterprise, we can handle your important emails. Our world-class platform delivers more than 50 billion emails per month.

Email Expertise

With SendGrid, you have an expert in your corner. Our Customer Success and Support Teams give you the information and guidance you need, when you need it.

Send With Confidence

Partner with the email service trusted by developers and marketers for time-savings, scalability, and delivery expertise.

See Plans and Pricing