Skip to content

Instantly share code, notes, and snippets.

View andreeacretu's full-sized avatar

Andreea andreeacretu

View GitHub Profile
<?php
// first add the header of the CSV file. The CSV file needs to be in the same place as this PHP script
$header = "email" . "\n";
file_put_contents('filename.csv', $header, FILE_APPEND); // this is the command that adds the info from the $header variable on a line
//in the below example the script adds 1.000.000 addresses in the CSV, one on each line
for ($i=1; $i <=1000000; $i++)
{
$string = $i . "[email protected]\n"; //the address is built by concatenating the value of the variable
// "i" to the rest of the email address. At the end we add \n to jump on a
//new line so that the next address will be added on a new line.
require 'rubygems'
require 'httparty'
require 'csv'
url = 'https://api.sendgrid.com/api/unsubscribes.add.json'
username = 'sg_username'
password = 'sg_passwd'
arr_of_addresses = []
# Opens the CSV from where you'll add the addresses to unsubscribe list
@andreeacretu
andreeacretu / subuser.php
Created March 18, 2016 13:32
Get subuser list PHP
<?php
$url = 'https://api.sendgrid.com/';
$user = 'SG_username';
$pass = 'SG_password';
$params = array(
'api_user' => $user,
'api_key' => $pass,
'task' => 'get',
@andreeacretu
andreeacretu / VBA Sendgrid
Created February 29, 2016 12:31 — forked from iolaru/VBA Sendgrid
VBA Sendgrid API example provided by user
Dim reportName As String
Dim path As String
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim oFile As Object
Dim strAttachments As String
Dim strTransPort As String
Dim byteData() As Byte
Dim xmlhttp As Object
Dim eTo As String
@andreeacretu
andreeacretu / gist:520b3f5f7ac3cb6433bd
Created February 29, 2016 12:31 — forked from iolaru/gist:05e115096f6e440e5698
Code example provided by user for sending emails with PDF attachments from Salesforce.com using Sendgrid API v2
global class SendGrid {
private static final String ENCODING = 'UTF-8';
private static final String API_URL = 'https://api.sendgrid.com/api/mail.send.json';
private transient String username;
private transient String password;
private transient String apikey;
private enum AUTHTYPE {KEY, USER_PASS}
private AUTHTYPE selAuthType;