# Paubox Gem
This gem and Paubox Transactional Email HTTP API are currently in pre-alpha development.
This is the official Ruby wrapper for the Paubox Transactional Email HTTP API. The Paubox Transactional Email API allows your application to send secure, HIPAA-compliant email via Paubox and track deliveries and opens.
It extends the [Ruby Mail Library](https://github.com/mikel/mail) for seamless integration in your existing Ruby application. The API wrapper also allows you to construct and send messages directly without the Ruby Mail Library.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'paubox'
```
And then execute:
$ bundle install
Or install it yourself as:
$ gem install paubox
### Getting Paubox API Credentials
You will need to have a Paubox account. Please contact [Paubox Customer Success](https://paubox.zendesk.com/hc/en-us) for details on gaining access to the Transactional Email API alpha testing program.
### Configuring API Credentials
To set your API credentials you'll need to include these in an initializer (config/initializers/paubox.rb in Rails).
Be careful not to commit your API credentials to version control. It's best to store these in environmental variables.
Paubox.configure do |config|
config.api_key = ENV['PAUBOX_API_KEY']
config.api_user = ENV['PAUBOX_API_USER']
end
### Sending Messages with the Ruby Mail Library
If you're already using the Ruby Mail Library, sending via Paubox is easy. Just build your message as normal and set Mail::Paubox as the delivery method.
message = Mail.new do
from 'you@yourdomain.com'
to 'someone@somewhere.com'
subject 'HIPAA-compliant email made easy'
text_part do
body 'This message will be sent securely by Paubox.'
end
html_part do
content_type 'text/html; charset=UTF-8'
body '
This message will be sent securely by Paubox.
'
end
delivery_method Mail::Paubox
end
message.deliver!
=> {"message"=>"Service OK", "sourceTrackingId"=>"2a3c048485aa4cf6"}
message.source_tracking_id
=> "2a3c048485aa4cf6"
### Sending Messages without ensuring TLS
If you want to send non-PHI mail that does not need to be HIPAA-compliant, you can allow the message delivery to take place even if a TLS connection is unavailable.
message = Mail.new do
from 'you@yourdomain.com'
to 'someone@somewhere.com'
subject 'Sending non-PHI'
body 'This message delivery will not enforce TLS transmission.'
delivery_method Mail::Paubox
end
message.allow_non_tls = true
message.deliver!
### Sending Messages using just the Paubox API
args = { from: 'you@yourdomain.com',
to: 'someone@domain.com, someone_else@domain.com',
cc: ['another@domain.com', 'yetanother@domain.com'],
bcc: 'bcc-recipient@domain.com',
reply_to: 'reply-to@yourdomain.com',
subject: 'Testing!',
text_content: 'Hello World!',
html_content: 'Hello World!
' }
message = Message.new(args)
client = Paubox::Client.new
client.deliver_mail(message)
=> {"message"=>"Service OK", "sourceTrackingId"=>"2a3c048485aa4cf6"}
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/paubox/paubox_ruby.
## License
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
## Copyright
Copyright © 2018, Paubox Inc.