NAME
Mail::Builder - Easily create e-mails with attachments, html and inline
images
SYNOPSIS
use Mail::Builder;
my $mail = Mail::Builder->new();
$mail->from('mightypirate@meele-island.mq','Guybrush Threepwood');
$mail->to->add('manuel.calavera@dod.mx','Manuel Calavera');
$mail->cc->add('glotis@dod.mx');
$mail->subject('Party at Sam\'s place');
$mail->htmltext('
Party invitation
... ');
$mail->attachment->add('direction_samandmax.pdf');
my $message = $mail->stringify;
DESCRIPTION
This module helps you to build e-mails with attachments, inline images,
multiple recipients without having to worry about the underlying MIME
stuff. Mail::Builder relies heavily on the MIME::Entity module from the
MIME::Tools distribution.
The module will create the correct MIME bodies, headers and containers
(multipart/mixed, multipart/related, multipart/alternative) depending on
if you use attachments, HTML text and inline images.
USAGE
new()
This is a simple constructor. It does not expect any parameters.
from, returnpath, reply
$obj->from(EMAIL[,NAME])
OR
$obj->from(Mail::Builder::Address)
This accessor always returns a Mail::Builder::Address object. If
parameters are provided the object will be replaced. You can either
suppy a Mail::Builder::Address object, or an e-mail address with an
optional name.
to, cc, bcc
$obj->to(Mail::Builder::List)
OR
$obj->to(Mail::Builder::Address)
OR
$obj->to(EMAIL[,NAME])
OR
$obj->to->add(EMAIL[,NAME])
OR
$obj->to->add(Mail::Builder::Address)
This accessor always returns a Mail::Builder::List object. If you supply
a Mail::Builder::List the object will be replaced. If you supply a
Mail::Builder::Address object or an e-mail address (with an optional
name), the new address will be appended to the list of recipients. The
Mail::Builder::List package provides some basic methods for manipulating
the list of recipients.
organization
Accessor for the name of the senders organisation.
prioriy
Priority accessor. Takes values from 1 to 5. The default priority is 3.
subject
e-mail subject accessor.
charset
charset accessor. Defaults to utf8.
htmltext
HTML mail body accessor.
plaintext
Plaintext mail body accessor. This text will be autogenerated from
htmltext if not provided by the user. Simple formating (e.g. ,
) will be converted to pseudo formating.
attachment
$obj->attachment(Mail::Builder::List)
OR
$obj->attachment(Mail::Builder::Attachment)
OR
$obj->attachment(PATH[,NAME,MIME])
OR
$obj->attachment->add(PATH[,NAME,MIME])
OR
$obj->attachment->add(Mail::Builder::Attachment)
This accessor always returns a Mail::Builder::List object. If you supply
a Mail::Builder::List object it will be replaced. If you supply a
Mail::Builder::Attachment object or a path to a file (with an optional
name an mime type), the new attachment will be appended to the list.
image
$obj->image(Mail::Builder::List)
OR
$obj->image(Mail::Builder::Image)
OR
$obj->image(PATH[,ID])
OR
$obj->image->add(PATH[,ID])
OR
$obj->image->add(Mail::Builder::Image)
This accessor always returns a Mail::Builder::List object. If you supply
a Mail::Builder::List object it will be replaced. If you supply a
Mail::Builder::Image object or a path to a file (with an optional id),
the new image will be appended to the list.
You can embed the image into the html mail body code by referencing the
ID. If you didn't provide an ID the lowercase filename without the
extension will be used.
Only jpg, gif and png images may be added as inline images.
stringify
Returns the e-mail message as a string. This string can be passed to
modules like Email::Send.
build_message
Returns the e-mail message as a MIME::Entity object. You can mess
arround with the object, change parts, ... as you wish.
Every time you call build_message the MIME::Entity object will be
rebuild, which can take some time if you are sending the e-mail to many
recipients. In order to increase the speed of the module the
Mail::Builder::Attachment and Mail::Builder::Image entities will be
cached and only rebuilt if something has changed.
SUPPORT
Please report any bugs or feature requests to
"bug-mail-builder@rt.cpan.org", or through the web interface at
. I will be notified, and then you'll automatically
be notified of progress on your bug as I make changes.
AUTHOR
Maros Kollar
CPAN ID: MAROS
maros [at] k-1.com
http://www.k-1.com
COPYRIGHT
Mail::Builder is Copyright (c) 2006,2007 Maroš Kollár. All rights
reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included
with this module.
SEE ALSO
The Mime::Entity module in the Mime::Tools distribution.