Skip to content

Instantly share code, notes, and snippets.

View sendgrid-gists's full-sized avatar

SendGrid DX sendgrid-gists

View GitHub Profile
@sendgrid-gists
sendgrid-gists / hello-email.sh
Last active May 11, 2016 17:43
"Hello World" for email, using SendGrid with cURL.
curl -X POST https://api.sendgrid.com/api/mail.send.json \
-H "Authorization: Bearer SENDGRID_APIKEY" \
-d "to=test@sendgrid.com" \
-d "from=you@youraddress.com" \
-d "subject=Sending with SendGrid is Fun" \
-d "html=and easy to do anywhere, even with cURL"
@sendgrid-gists
sendgrid-gists / hello-email.js
Last active May 11, 2016 17:44
"Hello World" for email, using SendGrid with Node.js.
// using SendGrid's Node.js Library
// https://github.com/sendgrid/sendgrid-nodejs
var sendgrid = require("sendgrid")("SENDGRID_APIKEY");
var email = new sendgrid.Email();
email.addTo("test@sendgrid.com");
email.setFrom("you@youremail.com");
email.setSubject("Sending with SendGrid is Fun");
email.setHtml("and easy to do anywhere, even with Node.js");
@sendgrid-gists
sendgrid-gists / hello-email.rb
Last active May 11, 2016 17:45
"Hello World" for email, using SendGrid with Ruby.
# using SendGrid's Ruby Library
# https://github.com/sendgrid/sendgrid-ruby
require 'sendgrid-ruby'
sendgrid = SendGrid::Client.new do |c|
c.api_key = 'SENDGRID_APIKEY'
end
email = SendGrid::Mail.new do |m|
m.to = 'test@sendgrid.com'
@sendgrid-gists
sendgrid-gists / hello-email.py
Last active May 11, 2016 17:46
"Hello World" for email, using SendGrid with Python.
# using SendGrid's Python Library
# https://github.com/sendgrid/sendgrid-python
import sendgrid
client = sendgrid.SendGridClient("SENDGRID_APIKEY")
message = sendgrid.Mail()
message.add_to("test@sendgrid.com")
message.set_from("you@youremail.com")
message.set_subject("Sending with SendGrid is Fun")
@sendgrid-gists
sendgrid-gists / hello-email.go
Last active May 11, 2016 17:46
"Hello World" for email, using SendGrid with Go.
// using SendGrid's Go Library
// https://github.com/sendgrid/sendgrid-go
package main
import (
"github.com/sendgrid/sendgrid-go"
)
func main() {
sg := sendgrid.NewSendGridClientWithApiKey("SENDGRID_APIKEY")
@sendgrid-gists
sendgrid-gists / hello-email.php
Last active May 20, 2016 20:47
"Hello World" for email, using SendGrid with PHP.
<?php
// using SendGrid's PHP Library
// https://github.com/sendgrid/sendgrid-php
require 'vendor/autoload.php';
$sendgrid = new SendGrid("SENDGRID_APIKEY");
$email = new SendGrid\Email();
$email->addTo("test@sendgrid.com")
->setFrom("you@youremail.com")
->setSubject("Sending with SendGrid is Fun")
@sendgrid-gists
sendgrid-gists / hello-email.java
Last active May 11, 2016 17:47
"Hello World" for email, using SendGrid with Java.
// 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(SENDGRID_APIKEY);
SendGrid.Email email = new SendGrid.Email();
@sendgrid-gists
sendgrid-gists / hello-email.cs
Last active May 11, 2016 17:47
"Hello World" for email, using SendGrid with C#.
// using SendGrid's C# Library
// https://github.com/sendgrid/sendgrid-csharp
using System.Net.Http;
using System.Net.Mail;
var myMessage = new SendGrid.SendGridMessage();
myMessage.AddTo("test@sendgrid.com");
myMessage.From = new MailAddress("you@youremail.com", "First Last");
myMessage.Subject = "Sending with SendGrid is Fun";
myMessage.Text = "and easy to do anywhere, even with C#";
POST https://api.sendgrid.com/v3/campaigns HTTP/1.1
@sendgrid-gists
sendgrid-gists / v3-hello-email.js
Last active September 28, 2020 19:53
v3 "Hello World" for email, using SendGrid with Node.js.
// using Twilio SendGrid's v3 Node.js Library
// https://github.com/sendgrid/sendgrid-nodejs
javascript
const sgMail = require('@sendgrid/mail')
sgMail.setApiKey(process.env.SENDGRID_API_KEY)
const msg = {
to: 'test@example.com', // Change to your recipient
from: 'test@example.com', // Change to your verified sender
subject: 'Sending with SendGrid is Fun',
text: 'and easy to do anywhere, even with Node.js',