1Email::Template(3)    User Contributed Perl Documentation   Email::Template(3)
2
3
4

NAME

6       Email::Template - Send "multipart/alternative" (text & html) email from
7       a Template
8

VERSION

10       Version 0.02
11

SYNOPSIS

13           use Email::Template;
14           Email::Template->send( '/path/to/email/template.tt2',
15               {
16                   From    => 'sender@domain.tld',
17                   To      => 'recipient@domain.tld',
18                   Subject => 'Email::Template is easy to use',
19
20                   tt_vars => { key => $value, ... },
21                   convert => { rightmargin => 80, no_rowspacing => 1, ... }
22               }
23           ) or warn "could not send the email";
24

DESCRIPTION

26       This is a fairly simple interface to generate "multipart/alternative"
27       emails with both "text/html" and "text/plain" components using a single
28       HTML based Template Toolkit template.
29
30       The HTML, once processed by Template Toolkit, is converted to text
31       using HTML::FormatText::WithLinks::AndTables. Both HTML and text
32       versions are then attached and sent via MIME::Lite.
33
34       Be sure to validate your sender and recipient addresses first (ie.
35       Email::Valid->rfc822 ).
36

A NOTE ABOUT CHARACTER SETS

38       If your template files are non-ASCII, be sure to pass { ENCODING =>
39       'utf-8' } (or whatever) in the tt_new argument; otherwise, you will get
40       gibberish in the emails.
41
42       The text/html and text/plain parts are encoded using utf-8 by default,
43       or pass in 'charset' to choose a different one (e.g. iso-8859-1).
44

EXPORTS

46       None by default.
47

METHODS

49   send
50       The first argument to send() is the path to the Template file. Absolute
51       paths are allowed.  If the path is relative, it works the same as when
52       using Template Toolkit.
53
54       The second argument to send() is a hash reference containing the
55       following possible options.
56
57       MIME::Lite
58
59           # REQUIRED
60
61               From    => 'sender@domain.tld',
62               To      => 'recipient@domain.tld',
63               Subject => 'a subject for your email',
64
65           # OPTIONAL
66
67               # charset to use for the text and html MIME parts (default utf-8)
68               charset => 'utf-8',
69
70               # arguments to be passed to MIME::Lite send()
71               mime_lite_send => ['smtp', 'some.host', Debug=>1 ],
72
73               # additional attachments to add via MIME::Lite attach()
74               mime_lite_attach => [ {Type=>...,Data=>...}, ... ],
75
76               # do not send(), just return the prepared MIME::Lite object
77               return_mime_lite => 1,
78
79       Template Toolkit
80
81           # OPTIONAL
82
83               # configuration options passed into Template->new()
84               tt_new  => { INCLUDE_PATH => '/path/to/templates', ... },
85
86               # variables to interpolate via Template->process()
87               tt_vars => { key => $value, ... },
88
89       HTML::FormatText::WithLinks::AndTables
90
91           # OPTIONAL
92
93               # configuration options passed into convert()
94               convert => { rm => 80, no_rowspacing => 1, ... }
95
96       NOTE: all additional arguments not explicitely mentioned above will be
97       passed into MIME::Lite->new()
98
99       Assuming "return_mime_lite => 1" was not passed in the arguments list,
100       on success send() returns the value of MIME::Lite->as_string(), or on
101       failure returns nothing.
102

SEE ALSO

104           Template
105           MIME::Lite
106           HTML::FormatText::WithLinks::AndTables
107

AUTHOR

109       Shaun Fryer, "<pause.cpan.org at sourcery.ca>"
110

CONTRIBUTORS

112       Ryan D Johnson, "<ryan@innerfence.com>", charset support
113

BUGS

115       Please report any bugs or feature requests to "bug-email-template at
116       rt.cpan.org", or through the web interface at
117       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Email-Template>.  I
118       will be notified, and then you'll automatically be notified of progress
119       on your bug as I make changes.
120

SUPPORT

122       You can find documentation for this module with the perldoc command.
123
124           perldoc Email::Template
125
126       You can also look for information at:
127
128       •   RT: CPAN's request tracker
129
130           <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Email-Template>
131
132       •   AnnoCPAN: Annotated CPAN documentation
133
134           <http://annocpan.org/dist/Email-Template>
135
136       •   CPAN Ratings
137
138           <http://cpanratings.perl.org/d/Email-Template>
139
140       •   Search CPAN
141
142           <http://search.cpan.org/dist/Email-Template>
143

ACKNOWLEDGEMENTS

145       Everybody. :)
146       <http://en.wikipedia.org/wiki/Standing_on_the_shoulders_of_giants>
147
149       Copyright 2008 Shaun Fryer, all rights reserved.
150
151       This program is free software; you can redistribute it and/or modify it
152       under the same terms as Perl itself.
153
154
155
156perl v5.38.0                      2023-07-20                Email::Template(3)
Impressum