Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eddiezane/smtpapi-ruby
Build SendGrid X-SMTPAPI headers in Ruby.
https://github.com/eddiezane/smtpapi-ruby
Last synced: about 1 month ago
JSON representation
Build SendGrid X-SMTPAPI headers in Ruby.
- Host: GitHub
- URL: https://github.com/eddiezane/smtpapi-ruby
- Owner: eddiezane
- License: mit
- Created: 2014-07-11T21:59:14.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2021-02-15T22:15:11.000Z (almost 4 years ago)
- Last Synced: 2024-10-14T11:47:39.167Z (2 months ago)
- Language: Ruby
- Homepage:
- Size: 14.6 KB
- Stars: 1
- Watchers: 2
- Forks: 46
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# smtpapi-ruby
This ruby gem allows you to quickly and more easily generate SendGrid X-SMTPAPI headers.
[![Build Status](https://travis-ci.org/SendGridJP/smtpapi-ruby.svg?branch=master)](https://travis-ci.org/SendGridJP/smtpapi-ruby)
## Installation
Add this line to your application's Gemfile:
gem 'smtpapi'
And then execute:
$ bundle
Or install it yourself as:
$ gem install smtpapi
## Usage
### Initializing
```ruby
header = Smtpapi::Header.new
```### to_json
This gives you back the stringified json formatted X-SMTPAPI header.
```ruby
header = Smtpapi::Header.new
header.to_json
```### add_to
```ruby
header = Smtpapi::Header.new
header.add_to('[email protected]')
header.add_to('[email protected]')
```### set_tos
```ruby
header = Smtpapi::Header.new
header.set_tos(['[email protected]', '[email protected]'])
```### add_substitution
```ruby
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']}
```### set_substitutions
```ruby
header = Smtpapi::Header.new
header.set_substitutions({'keep' => 'secret'}) # sub = {keep: ['secret']}
```### add_unique_arg
```ruby
header = Smtpapi::Header.new
header.add_unique_arg('cat', 'dogs')
```### set_unique_args
```ruby
header = Smtpapi::Header.new
header.set_unique_args({'cow' => 'chicken'})
header.set_unique_args({'dad' => 'proud'})
```### add_category
```ruby
header = Smtpapi::Header.new
header.add_category('tactics') # category = ['tactics']
header.add_category('advanced') # category = ['tactics', 'advanced']
```### set_categories
```ruby
header = Smtpapi::Header.new
header.set_categories(['tactics', 'advanced']) # category = ['tactics', 'advanced']
```### add_section
```ruby
header = Smtpapi::Header.new
header.add_section('-charge-', 'This ship is useless.'])
header.add_section('-bomber-', 'Only for sad vikings.'])
```### set_sections
```ruby
header = Smtpapi::Header.new
header.set_sections({'-charge-' => 'This ship is useless.'})
```### add_filter
```ruby
header = Smtpapi::Header.new
header.add_filter('footer', 'enable', 1)
header.add_filter('footer', 'text/html', 'boo')
```### set_filters
```ruby
header = Smtpapi::Header.new
filter = {
'footer' => {
'setting' => {
'enable' => 1,
"text/plain" => 'You can haz footers!'
}
}
}
header.set_filters(filter)
```### set_send_at
```ruby
header = Smtpapi::Header.new
lt = Time.local(2014, 8, 29, 17, 56, 35)
header.set_send_at(lt)
```### set_send_each_at
```ruby
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])
```## Contributing
1. Fork it ( http://github.com/sendgridjp/smtpapi-ruby/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request## Running Tests
The existing tests in the `test` directory can be run using test gem with the following command:
```bash
rake test
```