Project

mailx_ruby

0.0
No commit activity in last 3 years
No release in over 3 years
Ruby wrapper for mailx command
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.8.17
~> 0.10
~> 3.5

Runtime

>= 1.7
>= 1.8
 Project Readme

MailxRuby

NYU Build Status Code Climate Coverage Status

Simple Ruby wrapper for mailx command.

Installation

gem 'mailx_ruby'
require 'mailx_ruby'

Usage

You need at least a body and receiver to send mail:

MailxRuby.send_mail body: "Hello world!", to: "joe@example.com"

You can also specify subject, CC, and BCC:

MailxRuby.send_mail(
  body: "Hello world!",
  subject: "Hello",
  to: "joe@example.com",
  cc: "cc@example.com",
  bcc: ["bcc@example.com", "bcc.again@example.com"]
)

Options :to, :cc, and :bcc accept strings or arrays of strings.

Option :body accepts multi-line strings.

HTML

You can specify html: true, and MailxRuby will attempt to send the body as HTML on supported OSs (including Mac OS X 10.11 and RHEL 6.5):

body = "<p>Hello world! Here's a list:
<ul>
  <li>Item 1</li>
  <li>Item 2</li>
</ul>"
MailxRuby.send_mail(body: body, to: "joe@example.com", html: true)

If the HTML body includes CSS styles, MailxRuby will automatically convert the CSS to email-supported inline styles using the premailer gem.