Socket
Book a DemoInstallSign in
Socket

outbox

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

outbox

0.2.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

Outbox

Gem Version

Outbox is a factory for creating notifications in a variety of protocols, including: email, SMS, and push notifications. Each protocol is built as a generic interface where the actual delivery method or service can be configured independently of the message itself.

Installation

Add this line to your application's Gemfile:

gem 'outbox'

And then execute:

$ bundle

Or install it yourself as:

$ gem install outbox

Support

This gem is still in early development with plans to support email, SMS, and push notificaitons. As protocols and services are added, this support table will be updated:

Email

ServiceAliasClientGem
Mail gem:mailOutbox::Clients::MailClientIncluded

SMS

ServiceAliasClientGem
Twilio:twilioOutbox::Twilio::Clientoutbox-twilio

Push

TODO…

Usage

Outbox is inspired by Mail's syntax for creating emails.

Making a Message

An Outbox message is actually a factory for creating many different types of messages with the same topic. For example: a topic could be an event reminder in a calendar application. You want to send out essentially the same content (the reminder) as an email, SMS, and/or push notifications depending on user preferences:

message = Outbox::Message.new do
  email do
    from 'noreply@myapp.com'
    subject 'You have an upcoming event!'
  end

  sms do
    from '+15557654321'
  end

  ios_push do
    badge '+1'
    sound 'default'
  end

  body "Don't forget, you have an upcoming event on 8/15/2013."
end

# This will deliver the message to User's given contact points.
message.deliver(
  email: 'user@gmail.com',
  sms: '+15551234567',
  ios_push: 'FE66489F304DC75B8D6E8200DFF8A456E8DAEACEC428B427E9518741C92C6660'
)

Making an email

Making just an email is done just how you would using the Mail gem, so look there for in-depth examples. Here's a simple one to get you started:

email = Outbox::Messages::Email.new do
  to 'user@gmail.com'
  from 'noreply@myapp.com'
  subject 'You have an upcoming event!'

  text_part do
    body "Don't forget, you have an upcoming event on 8/15/2013."
  end

  html_part do
    body "<h1>Event Reminder</h1>..."
  end
end

# Configure the client. If you use the MailClient, you can specify
# the actual delivery method:
email.client :mail, delivery_method: :smtp, smtp_settings: {}

# And deliver using the specified client
email.deliver

Configuration

Configuration can be done in two ways:

1. Configure clients as you need them

mail_client = Outbox::Clients::MailClient.new(
  delivery_method: :smtp,
  smtp_settings: {}
)
sms_client = Outbox::Twilio::Client.new(
  account_sid: 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  auth_token: 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
)
message = Outbox::Message.new do
  email do
    client(mail_client)
    # content...
  end

  sms do
    client(sms_client)
    # content...
  end
end

2. Configure a default client for each message type

Outbox::Messages::Email.default_client(
  :mail,
  delivery_method: :smtp,
  smtp_settings: {}
)
Outbox::Messages::SMS.default_client(
  :twilio,
  account_sid: 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  auth_token: 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
)
message = Outbox::Message.new do
  email do
    # content...
  end

  sms do
    # content...
  end
end

Contributing

  • Fork it
  • 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

FAQs

Package last updated on 01 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.