Email::Template(3)
π Email::Template π
okay bestie, so this is the Email::Template page from the Perl manual (section 3, the library-call one, iykyk) β¨
πΈ NAME πΈ
Email::Template β send multipart/alternative (text & html) email from a Template π
β¨ VERSION β¨
Version 0.02 π
π¦ SYNOPSIS π¦
use Email::Template;
Email::Template->send( '/path/to/email/template.tt2',
{
From => 'sender@domain.tld',
To => 'recipient@domain.tld',
Subject => 'Email::Template is easy to use',
tt_vars => { key => $value, ... },
convert => { rightmargin => 80, no_rowspacing => 1, ... }
}
) or warn "could not send the email";
π DESCRIPTION π
okay so this is a pretty simple interface, no cap. It generates multipart/alternative emails that have both a text/html and a text/plain component, and you only have to write one HTML-based Template Toolkit template. one template, two parts. the way that works?? iconic π
Here's the pipeline, bestie: the HTML gets processed by Template Toolkit, and then it's converted to text using HTML::FormatText::WithLinks::AndTables. Then both versions β HTML and text β get attached and sent via MIME::Lite. slay.
fr fr, validate your sender and recipient addresses first (ie. Email::Valid->rfc822 ). do not skip this one π«Ά
π A NOTE ABOUT CHARACTER SETS π
If your template files are non-ASCII, be sure to pass { ENCODING => 'utf-8' } (or whatever) in the tt_new argument β otherwise, you will get gibberish in the emails. and not the fun kind π
The text/html and text/plain parts are encoded using utf-8 by default, or you can pass in 'charset' to choose a different one (e.g. iso-8859-1). pick your fighter π
π EXPORTS π
None by default. literally nothing, she gives you nothing for free π
β METHODS β
π send π
The first argument to send() is the path to the Template file. Absolute paths are allowed. If the path is relative, it works the same as when using Template Toolkit. same vibe either way β¨
The second argument to send() is a hash reference containing the following possible options.
π MIME::Lite π
# REQUIRED
From => 'sender@domain.tld',
To => 'recipient@domain.tld',
Subject => 'a subject for your email',
# OPTIONAL
# charset to use for the text and html MIME parts (default utf-8)
charset => 'utf-8',
# arguments to be passed to MIME::Lite send()
mime_lite_send => ['smtp', 'some.host', Debug=>1 ],
# additional attachments to add via MIME::Lite attach()
mime_lite_attach => [ {Type=>...,Data=>...}, ... ],
# do not send(), just return the prepared MIME::Lite object
return_mime_lite => 1,
π§ Template Toolkit π§
# OPTIONAL
# configuration options passed into Template->new()
tt_new => { INCLUDE_PATH => '/path/to/templates', ... },
# variables to interpolate via Template->process()
tt_vars => { key => $value, ... },
πΈ HTML::FormatText::WithLinks::AndTables πΈ
# OPTIONAL
# configuration options passed into convert()
convert => { rm => 80, no_rowspacing => 1, ... }
NOTE: all additional arguments not explicitely mentioned above will be passed into MIME::Lite->new() π
Assuming return_mime_lite => 1 was not passed in the arguments list, on success send() returns the value of MIME::Lite->as_string(), or on failure returns nothing. that's the whole deal π«Ά
π SEE ALSO π
Template
MIME::Lite
HTML::FormatText::WithLinks::AndTables
π AUTHOR π
Shaun Fryer, "<pause.cpan.org at sourcery.ca>"
π CONTRIBUTORS π
Ryan D Johnson, "<ryan@innerfence.com>", charset support β thank you for your service, king π
π BUGS π
Please report any bugs or feature requests to "bug-email-template at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Email-Template>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. bestie, you'll get updates. we got you π¬
π SUPPORT π
You can find documentation for this module with the perldoc command.
perldoc Email::Template
You can also look for information at:
- RT: CPAN's request tracker
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Email-Template>
- AnnoCPAN: Annotated CPAN documentation
<http://annocpan.org/dist/Email-Template>
- CPAN Ratings
<http://cpanratings.perl.org/d/Email-Template>
- Search CPAN
<http://search.cpan.org/dist/Email-Template>
π ACKNOWLEDGEMENTS π
Everybody. :) <http://en.wikipedia.org/wiki/Standing_on_the_shoulders_of_giants>
π₯ COPYRIGHT & LICENSE π₯
Copyright 2008 Shaun Fryer, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie πβ¨ this cutie is Email::Template, version 0.02, perl v5.42.0, and she was dated 2025-07-25. go forth and send some gorgeous multipart emails, you absolute main character ππΈ
π¦ where this page comes from
- fedora 43: perl-Email-Template 0.02-29.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms