1Email::MIME::Creator(3)User Contributed Perl DocumentatioEnmail::MIME::Creator(3)
2
3
4

NAME

6       Email::MIME::Creator - Email::MIME constructor for starting anew.
7

SYNOPSIS

9         use Email::MIME::Creator;
10         use IO::All;
11
12         # multipart message
13         my @parts = (
14             Email::MIME->create(
15                 attributes => {
16                     filename     => "report.pdf",
17                     content_type => "application/pdf",
18                     encoding     => "quoted-printable",
19                     name         => "2004-financials.pdf",
20                 },
21                 body => io( "2004-financials.pdf" )->all,
22             ),
23             Email::MIME->create(
24                 attributes => {
25                     content_type => "text/plain",
26                     disposition  => "attachment",
27                     charset      => "US-ASCII",
28                 },
29                 body => "Hello there!",
30             ),
31         );
32
33         my $email = Email::MIME->create(
34             header => [ From => 'casey@geeknest.com' ],
35             parts  => [ @parts ],
36         );
37
38         # nesting parts
39         $email->parts_set(
40             [
41               $email->parts,
42               Email::MIME->create( parts => [ @parts ] ),
43             ],
44         );
45
46         # standard modifications
47         $email->header_set( 'X-PoweredBy' => 'RT v3.0'      );
48         $email->header_set( To            => rcpts()        );
49         $email->header_set( Cc            => aux_rcpts()    );
50         $email->header_set( Bcc           => sekrit_rcpts() );
51
52         # more advanced
53         $_->encoding_set( 'base64' ) for $email->parts;
54
55         # Quick multipart creation
56         my $quicky = Email::MIME->create(
57             header => [
58                 From => 'my@address',
59                 To   => 'your@address',
60             ],
61             parts => [
62                 q[This is part one],
63                 q[This is part two],
64                 q[These could be binary too],
65             ],
66         );
67
68         print $email->as_string;
69
70         *rcpts = *aux_rcpts = *sekrit_rcpts = sub { 'you@example.com' };
71

DESCRIPTION

73   Methods
74       create
75              my $single = Email::MIME->create(
76                header     => [ ... ],
77                attributes => { ... },
78                body       => '...',
79              );
80
81              my $multi = Email::MIME->create(
82                header     => [ ... ],
83                attributes => { ... },
84                parts      => [ ... ],
85              );
86
87            This method creates a new MIME part. The "header" parameter is a
88            lis of headers to include in the message. "attributes" is a hash
89            of MIME attributes to assign to the part, and may override
90            portions of the header set in the "header" parameter.
91
92            The "parts" parameter is a list reference containing "Email::MIME"
93            objects. Elements of the "parts" list can also be a non-reference
94            string of data. In that case, an "Email::MIME" object will be
95            created for you. Simple checks will determine if the part is
96            binary or not, and all parts created in this fashion are encoded
97            with "base64", just in case.
98
99            "parts" takes precedence over "body", which will set this part's
100            body if assigned. So, multi part messages shold use the "parts"
101            parameter and single part messages should use "body".
102
103            Back to "attributes". The hash keys correspond directly to methods
104            or modifying a message from "Email::MIME::Modifier". The allowed
105            keys are: content_type, charset, name, format, boundary, encoding,
106            disposition, and filename. They will be mapped to "$attr\_set" for
107            message modification.
108

SEE ALSO

110       Email::MIME, Email::MIME::Modifier, Email::Simple::Creator, "IO::All"
111       or "File::Slurp" (for file slurping to create parts from strings),
112       perl.
113

PERL EMAIL PROJECT

115       This module is maintained by the Perl Email Project.
116
117       <http://emailproject.perl.org/wiki/Email::MIME::Creator>
118

ORIGINAL AUTHOR

120       Do not send bug reports to: Casey West, <casey@geeknest.com>.
121
123         Copyright (c) 2004 Casey West.  All rights reserved.
124         This module is free software; you can redistribute it and/or modify it
125         under the same terms as Perl itself.
126
127
128
129perl v5.12.0                      2009-04-30           Email::MIME::Creator(3)
Impressum