NAME
Mail::Builder::Attachment::File - Module for handling attachments from files
SYNOPSIS
use Mail::Builder;
my $attachment = new Mail::Builder::Attachment::File('/home/guybrush/2007_10_11_invitation.pdf','invitation.pdf','application/pdf');
$attachment->name('party_invitation.pdf');
print $attachment->serialize;
# Append the attachment to an Mail::Builder object
$mb->attachment($attachment); # this removes all other attachments
OR
$mb->attachment->add($mail);
DESCRIPTION
This is a simple module for handling attachments with Mail::Builder.
METHODS
Constructor
new
my $obj = Mail::Builder::Attachment::File->new(PATH[,NAME,MIME]);
Takes the path to the attached file on the local filesystem. Optionally takes the file name as it should be diplayed in the e-mail message and a mime type.
Public methods
compare
$obj->compare(OBJECT);
or
$obj->compare(PATH);
Checks if two attachment objectscontain the same file. Returns true or false. The compare method does not check if the mime types and name attributes of the two objects are identical.
Instead of a Mail::Builder::Attachment::File
object you can also pass a scalar value representing the path.
serialize
Returns the attachment as a MIME::Entity object.
Accessors
path
Accessor which takes/returns the path of the file on the filesystem. The file must be readable by the current uid.
name
Accessor which takes/returns the name of the file as displayed in the e-mail message. If no name is provided the filename will be extracted from the path attribute.
mime
Accessor which takes/returns the mime type of the file. If no mime type is provided the module tries to determine the correct mime type for the given filename extension. If this fails 'application/octet-stream' will be used.
Private methods
_get_mime
Try to determine the mime type by parsing the filename.
_get_name
Fetch the e-mail filename from the path attribute.
AUTHOR
Maroš Kollár
CPAN ID: MAROS
maros [at] k-1.com
http://www.k-1.com