Skip to content

Instantly share code, notes, and snippets.

@sebmih
Created November 27, 2013 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebmih/7671438 to your computer and use it in GitHub Desktop.
Save sebmih/7671438 to your computer and use it in GitHub Desktop.
This script should send emails by with categories and unique args.
require '~/Dev/ruby/SmtpApiHeader.rb'
require 'mail'
Mail.defaults do
delivery_method :smtp, { :address => "smtp.sendgrid.net",
:port => 587,
:domain => "sendgrid.com",
:user_name => "sebfree",
:password => "*******",
:authentication => 'plain',
:enable_starttls_auto => true }
end
hdr = SmtpApiHeader.new
receiver = ['sebi.mihalache@gmail.com','sebi.mihalache@ymail.com']
hdr.addTo(receiver)
hdr.setUniqueArgs({'test' => 1, 'foo' =>2})
hdr.setCategory("testingapi")
a = hdr.as_string()
print a
print "\n"
mail = Mail.deliver do
header['X-SMTPAPI'] = hdr.asJSON()
to receiver
from "seb@sendgrid.com"
subject "Ruby API 2"
text_part do
body 'This tests the Ruby API'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment