Created
November 27, 2013 06:20
-
-
Save sebmih/7671438 to your computer and use it in GitHub Desktop.
This script should send emails by with categories and unique args.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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