Mailthis

Description

Configure and send email using Mail (https://github.com/mikel/mail) over Net:SMTP.

Usage

A basic example

require 'mailthis'

GMAIL = Mailthis.mailer do
  smtp_helo   "example.com"
  smtp_server "smtp.gmail.com"
  smtp_port   587
  smtp_user   "[email protected]"
  smtp_pw     'secret'
end

GMAIL.deliver do
  subject 'a message for you'
  to      '[email protected]'
  body    'here is a message for you'
end

A more complex example

require 'mailthis'

GMAIL = Mailthis.mailer do
  smtp_helo   "example.com"
  smtp_server "smtp.gmail.com"
  smtp_port   587
  smtp_user   "[email protected]"
  smtp_pw     'secret'

  smtp_auth "plain"                     # (optional) default: "login"
  from      "[email protected]"            # (optional) default: config.smtp_username (if valid)
  logger    Logger.new("log/email.log") # (optional) default: no logger, no logging
end

msg = Mail.new
msg.from     = '[email protected]',       # (optional) default: mailer #from
msg.reply_to = '[email protected]',            # (optional) default: self #from
msg.to       = "[email protected]",
msg.cc       = "Another <[email protected]>",
msg.bcc      = ["[email protected]", "Two <[email protected]>"],
msg.subject  = "a message",
msg.body     = "a message body"

GMAIL.deliver(msg)

Installation

Add this line to your application's Gemfile:

gem 'mailthis'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mailthis

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request