Skip to content

Instantly share code, notes, and snippets.

@brandonmwest
brandonmwest / gist:6262934
Last active December 22, 2020 09:02
Custom liquid block for Jekyll example
#Generates a named anchor and wrapping tag from a string.
module Jekyll
class AnchorBlock < Liquid::Block
def initialize(tag_name, markup, tokens)
@tag = markup
super
end
def render(context)
<?xml version="1.0" encoding="UTF-8" ?>
<feedback>
<report_metadata>
<org_name>receiver.com</org_name>
<email>noreply-dmarc-support@receiver.com</email>
<extra_contact_info>http://receiver.com/dmarc/support</extra_contact_info>
<report_id>9391651994964116463</report_id>
<date_range>
<begin>1335571200</begin>
<end>1335657599</end>
@brandonmwest
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 => 'from@example.com',
to => 'to@example.com',
subject => 'Testing',
text => "Some text http://sendgrid.com/\n",
@brandonmwest
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
brandonmwest / gist:5016294
Created February 22, 2013 20:22
Send email from SendGrid using Pony gem
require 'rubygems'
require 'pony'
#set the default options
Pony.options = {
:from => 'demo@sendgrid.com',
:via => :smtp,
:via_options => {
:address => 'smtp.sendgrid.net',
:port => '587',
@brandonmwest
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
brandonmwest / gist:4512396
Last active June 25, 2022 13:11
curl + PHP example of using the SendGrid web api

This example uses cURL with PHP through our web API to send an email.

<?php $url = 'http://sendgrid.com/';
$user = 'USERNAME';
$pass = 'PASSWORD'; 
 
$params = array(
    'api_user'  => $user,
 'api_key' =&gt; $pass,
@brandonmwest
brandonmwest / fake_names.rb
Created September 5, 2012 02:35
Generate a csv of fake names and email addresses
require 'faker'
require 'csv'
CSV.open("output.csv", "wb") do |csv|
i=0
until i == 25000
fake = [Faker::Name.name, Faker::Internet.email]
csv << fake
i=i+1
end
@brandonmwest
brandonmwest / gist:3536551
Created August 30, 2012 18:23
Hierarchical tree of pages in Jekyll
require 'digest/md5'
module Jekyll
# Add accessor for directory
class Page
attr_reader :dir
end
class NavTree < Liquid::Tag
def render(context)
@brandonmwest
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