Class MailFactory
In: lib/mailfactory.rb
Parent: Object

An easy class for creating a mail message

Methods

Public Class methods

Public Instance methods

adds an attachment to the mail. Type may be given as a mime type. If it is left off and the MIME::Types module is available it will be determined automagically. If the optional attachemntheaders is given, then they will be added to the attachment boundary in the email, which can be used to produce Content-ID markers. attachmentheaders can be given as an Array or a String.

adds an attachment to the mail as emailfilename. Type may be given as a mime type. If it is left off and the MIME::Types module is available it will be determined automagically. file may be given as an IO stream (which will be read until the end) or as a filename. If the optional attachemntheaders is given, then they will be added to the attachment boundary in the email, which can be used to produce Content-ID markers. attachmentheaders can be given as an Array of a String.

adds a header to the bottom of the headers

attach(filename, type=nil, attachmentheaders = nil)

Alias for add_attachment

attach_as(file, emailfilename, type=nil, attachmentheaders = nil)

Alias for add_attachment_as

builds an email and returns it as a string. Takes the following options:

:messageid:Adds a message id to the message based on the from header (defaults to false)
:date:Adds a date to the message if one is not present (defaults to true)

generates a unique boundary string

returns the value (or values) of the named header in an array

sets the HTML body of the message. Only the body of the html should be provided

implement method missing to provide helper methods for setting and getting headers. Headers with ’-’ characters may be set/gotten as ‘x_mailer’ or ‘XMailer’ (splitting will occur between capital letters or on ‘_’ chracters)

returns true if the email is multipart

sets the HTML body of the message. The entire HTML section should be provided

removes the named header - case insensitive

sets a header (removing any other versions of that header)

sets the plain text body of the message

returns a formatted email - equivalent to construct(:messageid => true)

Protected Instance methods

returns the body as a properly formatted string

builds a boundary string for including attachments in the body, expects an attachment hash as built by add_attachment and add_attachment_as

builds a boundary string for inclusion in the body of a message

returns a base64 encoded version of the contents of str

returns the @headers as a properly formatted string

Quote the given address if it needs to be. The address may be a regular email address, or it can be a phrase followed by an address in brackets. The phrase is the only part that will be quoted, and only if it needs to be. This allows extended characters to be used in the "to", "from", "cc", and "bcc" headers.

Quote the given text if it contains any "illegal" characters

rfc2045 compatible. use rfc2047 for headers (such as the Subject line) instead

Convert the given character to quoted printable format see tools.ietf.org/html/rfc2047

Convert the given text into quoted printable format, with an instruction that the text be eventually interpreted in the given charset.

[Validate]