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

SEE ALSO

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

PERL EMAIL PROJECT

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

AUTHOR

121       Casey West, <casey@geeknest.com>.
122
124         Copyright (c) 2004 Casey West.  All rights reserved.
125         This module is free software; you can redistribute it and/or modify it
126         under the same terms as Perl itself.
127
128
129
130perl v5.8.8                       2007-04-19           Email::MIME::Creator(3)
Impressum