API client for Jobstar Messaging Service.
Add the following line to your Gemfile and run bundle install
:
gem 'messy', :git => 'git@github.com:pederbl/messy.git'
Create an initializer file in config/initializers
in which you'll set up the API url and token:
Messy.api_url = 'http://localhost:3000/api/v1'
Messy.api_token = '12345678901234567890'
Save the file and restart your application.
@email = Messy::Email.new
@email.subject = "Hi there"
@email.body = "Just a test email"
@email.recipients = "piotr.chmolowski@polcode.com"
@email.from = "Jobstar <jobstar@example.com>"
Messy::Emailer.send(email)
@email.attachments["file.pdf"] = File.read("/tmp/example/file.pdf")
Messy::Emailer.send(email)
Messy::Emailer.fetch_incoming_emails(last_id)
Messy::Emailer.fetch_outgoing_errors(last_id)
begin
Messy::Emailer.send(@email)
rescue Messy::InvalidData => e
errors = ActiveSupport::JSON.decode(e.to_s)
p errors
end