Skip to content

Latest commit

 

History

History
82 lines (53 loc) · 2.12 KB

README.md

File metadata and controls

82 lines (53 loc) · 2.12 KB

malone(1) -- send mail using smtp without any fuss

USAGE

require "malone"

# Typically you would do this somewhere in the bootstrapping
# part of your application

m = Malone.connect(url: "smtp://foo%40bar.com:[email protected]:587",
                   domain: "mysite.com")

m.deliver(from: "[email protected]", to: "[email protected]",
          subject: "Test subject", text: "Great!")

# Malone.current will now remember the last configuration you setup.
Malone.current.config == m.config

# Now you can also do Malone.deliver, which is syntactic sugar
# for Malone.current.deliver
Malone.deliver(from: "[email protected]", to: "[email protected]",
               subject: "Test subject", text: "Great!")

# Also starting with Malone 1.0, you can pass in :html
# for multipart emails.

Malone.deliver(from: "[email protected]", to: "[email protected]",
               subject: "Test subject",
               text: "Great!", html: "<b>Great!</b>")

TESTING

require "malone/test"

m = Malone.connect(url: "smtp://foo%40bar.com:[email protected]:587",
                   domain: "mysite.com")

m.deliver(from: "[email protected]", to: "[email protected]",
          subject: "Test subject", text: "Great!")

Malone.deliveries.size == 1
# => true

mail = Malone.deliveries.first

"[email protected]" == mail.from
# => true

"[email protected]" == mail.to
# => true

"FooBar" == mail.text
# => true

"Hello World" == envelope.subject
# => true

INSTALLATION

gem install malone

CONFIGURATION TIPS

If you're used to doing configuration via environment variables, similar to how Heroku does configuration, then you can simply set an environment variable in your production machine like so:

export MALONE_URL=smtp://foo%40bar.com:[email protected]:587

Then you can connect using the environment variable in your code like so:

Malone.connect(url: ENV["MALONE_URL"])

# or quite simply
Malone.connect

By default Malone tries for the environment variable MALONE_URL when you call Malone.connect without any arguments.