MIMEBuilder Ruby
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:
Content-DispositionContent-Transfer-EncodingContent-Type
This will optionally delete the following auto-generated header:
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:
Content-Id
builder = MIMEBuilder::Text.new 'Hi there!'
mime_part = builder.mime
Options:
builder = MIMEBuilder::Text(
'Hi there!',
content_id_disable: true, # remove auto-generated Content-Id header
content_type: 'text/html' # override auto-generated Content-Type
)
Change Log
See CHANGELOG.md
Links
Project Repo
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
