MIMEBuilder Ruby

Gem Version Build Status Coverage Status Dependency Status Code Climate Scrutinizer Code Quality Downloads Docs License

Overview

This library creates mime parts from limited information.

Installation

Via Bundler

Add 'mime_builder' to Gemfile and then run bundle:

$ echo "gem 'mime_builder'" >> Gemfile
$ bundle

Via RubyGems

$ gem install mime_builder

Usage

From Filepath

Builds a MIME::Application or MIME::Type object depending on whether base64 encoding is selected. This reads bytes from filesystem and populates the following MIME headers:

  1. Content-Disposition
  2. Content-Transfer-Encoding
  3. Content-Type

This will optionally delete the following auto-generated header:

  1. Content-Id
builder = MIMEBuilder::Filepath.new '/path/to/file'
mime_part = builder.mime

Options:

builder = MIMEBuilder::Filepath(
  '/path/to/file',
  {
    :base64_encode => true,        # base64 encode part
    :content_id_disable => true,   # remove auto-generated Content-Id header
    :content_type => 'text/plain', # override auto-generated Content-Type
    :is_attachment => true         # add 'attachment' disposition
  }
)

From String

Builds a MIME::Text object.

This will optionally delete the following auto-generated header:

  1. Content-Id
builder = MIMEBuilder::Text.new 'Hi there!' 
mime_part = builder.mime

Options:

builder = MIMEBuilder::Text.new 'Hi there!', :content_id_disable => true

Change Log

See CHANGELOG.md

Contributions

Any reports of problems, comments or suggestions are most welcome.

Please report these on Github

License

MIMEBuilder is available under an MIT-style license. See LICENSE.txt for details.

MIMEBuilder © 2016 by John Wang