Email::Template(3)

πŸ“¦
version 0.02 Β· 2 versions
, in fedora 43

πŸ’Œ 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, ... },
# 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 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