curl -X POST https://api.sendgrid.com/api/mail.send.json \
-d "api_user=YOUR_USERNAME" \
-d "api_key=YOUR_KEY" \
-d "[email protected]" \
-d "[email protected]" \
-d "subject=Sending with SendGrid is Fun" \
-d "html=and easy to do anywhere, even with CURL"
// using SendGrid's Node.js Library - https://github.com/sendgrid/sendgrid-nodejs
var sendgrid = require("sendgrid")(api_user, api_key);
var email = new sendgrid.Email();
email.addTo("[email protected]");
email.setFrom("[email protected]");
email.setSubject("Sending with SendGrid is Fun");
email.setHtml("and easy to do anywhere, even with Node.js");
sendgrid.send(email);
# using SendGrid's Ruby Library - https://github.com/sendgrid/sendgrid-ruby
require 'sendgrid-ruby'
sendgrid = SendGrid::Client.new(api_user: api_user, api_key: api_key)
email = SendGrid::Mail.new do |m|
m.to = '[email protected]'
m.from = '[email protected]'
m.subject = 'Sending with SendGrid is Fun'
m.html = 'and easy to do anywhere, even with Ruby'
end
sendgrid.send(email)
# using SendGrid's Python Library - https://github.com/sendgrid/sendgrid-python
import sendgrid
sendgrid = sendgrid.SendGridClient(api_user, api_key)
message = sendgrid.Mail()
message.add_to("[email protected]")
message.set_from("[email protected]")
message.set_subject("Sending with SendGrid is Fun")
message.set_html("and easy to do anywhere, even with Python")
sendgrid.send(message)
// using SendGrid's Go Library - https://github.com/sendgrid/sendgrid-go
package main
import ("github.com/sendgrid/sendgrid-go")
func main() {
sendgrid := sendgrid.NewSendGridClient(api_user, api_key)
message := sendgrid.NewMail()
message.AddTo("[email protected]")
message.SetFrom("[email protected]")
message.SetSubject("Sending with SendGrid is Fun")
message.SetHTML("and easy to do anywhere, even with Go")
sendgrid.Send(message)
}
// using SendGrid's PHP Library - https://github.com/sendgrid/sendgrid-php
$sendgrid = new SendGrid($api_user, $api_key);
$email = new SendGrid\Email();
$email->addTo("[email protected]")
->setFrom("[email protected]")
->setSubject("Sending with SendGrid is Fun")
->setHtml("and easy to do anywhere, even with PHP");
$sendgrid->send($email);
// using SendGrid's Java Library - https://github.com/sendgrid/sendgrid-java
import com.sendgrid.*;
public class SendGridExample {
public static void main(String[] args) {
SendGrid sendgrid = new SendGrid(api_user, api_key);
SendGrid.Email email = new SendGrid.Email();
email.addTo("[email protected]");
email.setFrom("[email protected]");
email.setSubject("Sending with SendGrid is Fun");
email.setHtml("and easy to do anywhere, even with Java");
SendGrid.Response response = sendgrid.send(email);
}
}
// using SendGrid's C# Library - https://github.com/sendgrid/sendgrid-csharp
using System;
using System.Net;
using System.Net.Mail;
using SendGridMail;
using SendGridMail.Transport;
SendGrid mail = SendGrid.GetInstance();
mail.From = new MailAddress("[email protected]");
mail.AddTo("[email protected]");
mail.Subject = "Sending with SendGrid is Fun";
mail.Text = "and easy to do anywhere, even with C#";
var credentials = new NetworkCredential(api_user, api_key);
var transportWeb = new Web(credentials);
transportWeb.Deliver(mail);
# using SendGrid's Perl Library - https://github.com/sendgrid/sendgrid-perl
use Mail::SendGrid;
use Mail::SendGrid::Transport::REST;
my $sendgrid = Mail::SendGrid->new(
from => "[email protected]",
to => "[email protected]",
subject => "Sending with SendGrid is Fun",
html => "and easy to do anywhere, even with Perl"
);
Mail::SendGrid::Transport::REST->new( username => $api_user, password => $api_key );