This ruby gem allows you to quickly and more easily generate SendGrid X-SMTPAPI headers.
Add this line to your application's Gemfile:
gem 'smtpapi'
And then execute:
$ bundle
Or install it yourself as:
$ gem install smtpapi
header = Smtpapi::Header.new
This gives you back the stringified json formatted X-SMTPAPI header.
header = Smtpapi::Header.new
header.to_json
header = Smtpapi::Header.new
header.add_to('[email protected]')
header.add_to('[email protected]')
header = Smtpapi::Header.new
header.set_tos(['[email protected]', '[email protected]'])
header = Smtpapi::Header.new
header.add_substitution('keep', array('secret')) # sub = {keep: ['secret']}
header.add_substitution('other', array('one', 'two')) # sub = {keep: ['secret'], other: ['one', 'two']}
header = Smtpapi::Header.new
header.set_substitutions({'keep' => 'secret'}) # sub = {keep: ['secret']}
header = Smtpapi::Header.new
header.add_unique_arg('cat', 'dogs')
header = Smtpapi::Header.new
header.set_unique_args({'cow' => 'chicken'})
header.set_unique_args({'dad' => 'proud'})
header = Smtpapi::Header.new
header.add_category('tactics') # category = ['tactics']
header.add_category('advanced') # category = ['tactics', 'advanced']
header = Smtpapi::Header.new
header.set_categories(['tactics', 'advanced']) # category = ['tactics', 'advanced']
header = Smtpapi::Header.new
header.add_section('-charge-', 'This ship is useless.'])
header.add_section('-bomber-', 'Only for sad vikings.'])
header = Smtpapi::Header.new
header.set_sections({'-charge-' => 'This ship is useless.'})
header = Smtpapi::Header.new
header.add_filter('footer', 'enable', 1)
header.add_filter('footer', 'text/html', '<strong>boo</strong>')
header = Smtpapi::Header.new
filter = {
'footer' => {
'setting' => {
'enable' => 1,
"text/plain" => 'You can haz footers!'
}
}
}
header.set_filters(filter)
header = Smtpapi::Header.new
lt = Time.local(2014, 8, 29, 17, 56, 35)
header.set_send_at(lt)
header = Smtpapi::Header.new
lt1 = Time.local(2014, 8, 29, 17, 56, 35)
lt2 = Time.local(2013, 12, 31, 0, 0, 0)
lt3 = Time.local(2015, 9, 1, 4, 5, 6)
header.set_send_each_at([lt1, lt2, lt3])
- Fork it ( http://github.com/sendgridjp/smtpapi-ruby/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
The existing tests in the test
directory can be run using test gem with the following command:
rake test