Skip to content

Instantly share code, notes, and snippets.

brandonmwest / create template
Last active August 29, 2015 14:01
SendGrid web api v3 curl example
curl -X POST -d '{"name":"example_name"}' -H "Content-Type: application/json" -u sendgrid_username
brandonmwest / no_tables.rb
Last active August 29, 2015 14:03
Convert tables to {% parameters %} liquid blocks
require 'rubygems'
require 'json'
require 'nokogiri'
require 'nokogiri-pretty'
require 'iconv'
require 'fileutils'
html_files = File.join("/Users/brandonwest/SendGrid/docs/source/API_Reference", "**", "*.{md,html}")
Dir.glob html_files do |html_file|
brandonmwest / webhook.rb
Last active August 29, 2015 14:15
Log a JSON payload in Sinatra
post '/event' do
status 204 #successful request with no body content
request_payload = JSON.parse(
#append the payload to a file"events.txt", "a") do |f|
"timestamp"=>1386636112, "smtp-id"=>"<>",
"category"=>["category1", "category2", "category3"],
brandonmwest / testing.php
Created February 28, 2012 16:23
Testing WP integration
include_once "lib/swift_required.php";
* Create the body of the message (a plain-text and an HTML version).
* $text is your plain-text email
* $html is your html version of the email
* If the reciever is able to view html emails then only the html
* email will be displayed
brandonmwest / gist:3384117
Created August 18, 2012 03:17
Adding recipients to the X-SMTPAPI Header with sendgrid-csharp
using System;
using System.Collections.Generic;
using SendGridMail;
using System.Net;
using SendGridMail.Transport;
using System.Net.Mail;
namespace EmailTester
class MainClass
brandonmwest / fake_names.rb
Created September 5, 2012 02:35
Generate a csv of fake names and email addresses
require 'faker'
require 'csv'"output.csv", "wb") do |csv|
until i == 25000
fake = [,]
csv << fake
brandonmwest / gist:4559791
Last active December 11, 2015 06:29
Windows Azure + SendGrid example

#How to: Create an email

Use the static SendGrid.GetInstance method to create an email message that is of type SendGrid. Once the message is created, you can use SendGrid properties and methods to set values including the email sender, the email recipient, and the subject and body of the email.

The following example demonstrates how to create an email object and populate it:

// Create the email object first, then add the properties.
var myMessage = SendGrid.GetInstance();
brandonmwest / prettyprint.rb
Created February 24, 2013 01:07
Jekyll filter for pretty-printing HTML
require 'rubygems'
require 'json'
require 'nokogiri'
require 'nokogiri-pretty'
require 'fileutils'
module Jekyll
module PrettyPrintFilter
def pretty_print(input)
#seeing some ASCII-8 come in
brandonmwest / gist:5663960
Created May 28, 2013 16:16
sendgrid-perl example
use warnings;
use strict;
use Mail::SendGrid;
use Mail::SendGrid::Transport::SMTP;
my $sg = Mail::SendGrid->new( from => '',
to => '',
subject => 'Testing',
text => "Some text\n",