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 "[email protected]" \
-d "[email protected]" \
-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("[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-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 = '[email protected]'
@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("[email protected]")
message.set_from("[email protected]")
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("[email protected]")
->setFrom("[email protected]")
->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("[email protected]");
myMessage.From = new MailAddress("[email protected]", "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: '[email protected]', // Change to your recipient
from: '[email protected]', // Change to your verified sender
subject: 'Sending with SendGrid is Fun',
text: 'and easy to do anywhere, even with Node.js',