NAME
Email::MIME::Creator - Email::MIME constructor for starting anew.
SYNOPSIS
use
Email::MIME;
use
Email::MIME::Creator;
use
IO::All;
# multipart message
my
@parts
= (
Email::MIME->create(
attributes
=> {
filename
=>
"report.pdf"
,
content_type
=>
"application/pdf"
,
encoding
=>
"quoted-printable"
,
name
=>
"2004-financials.pdf"
,
},
body
=> io(
"2004-financials.pdf"
)->slurp,
),
Email::MIME->create(
attributes
=> {
content_type
=>
"text/plain"
,
disposition
=>
"attachment"
,
charset
=>
"US-ASCII"
,
},
body
=>
"Hello there!"
,
),
);
my
= Email::MIME->create(
header
=> [
From
=>
'casey@geeknest.com'
],
parts
=> [
@parts
],
);
# nesting parts
->parts_set(
[
->parts,
Email::MIME->create(
parts
=> [
@parts
] ),
],
);
# standard modifications
->header_set(
'X-PoweredBy'
=>
'RT v3.0'
);
->header_set(
To
=> rcpts() );
->header_set(
Cc
=> aux_rcpts() );
->header_set(
Bcc
=> sekrit_rcpts() );
# more advanced
$_
->encoding_set(
'base64'
)
for
->parts;
->as_string;
*rcpts
=
*aux_rcpts
=
*sekrit_rcpts
=
sub
{
'you@example.com'
};
DESCRIPTION
Methods
- create
-
my
$single
= Email::MIME->create(
header
=> [ ... ],
attributes
=> { ... },
body
=>
'...'
,
);
my
$multi
= Email::MIME->create(
header
=> [ ... ],
attributes
=> { ... },
parts
=> [ ... ],
);
This method creates a new MIME part. The
header
parameter is a lis of headers to include in the message.attributes
is a hash of MIME attributes to assign to the part, and may override portions of the header set in theheader
parameter.The
parts
parameter is a list reference containingEmail::MIME
objects.parts
takes precedence overbody
, which will set this part's body if assigned. So, multi part messages shold use theparts
parameter and single part messages should usebody
.Back to
attributes
. The hash keys correspond directly to methods or modifying a message fromEmail::MIME::Modifier
. The allowed keys are: content_type, charset, name, format, boundary, encoding, disposition, and filename. They will be mapped to"$attr\_set"
for message modification.
SEE ALSO
Email::MIME, Email::MIME::Modifier, Email::Simple::Creator, perl.
AUTHOR
Casey West, <casey@geeknest.com>.
COPYRIGHT
Copyright (c) 2004 Casey West. All rights reserved.
This module is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.