Catalys...n::Email(3)
π Catalyst::Plugin::Email π
okay so bestie, welcome to Catalyst::Plugin::Email β it's a User Contributed Perl Documentation page, and the vibes are... deprecated π but we're gonna learn it anyway because knowing things is the whole point, iykyk β¨
πΈ NAME πΈ
Catalyst::Plugin::Email β (DEPRECATED) Send emails with Catalyst
not me putting DEPRECATED in all caps like that, that's literally how the original says it and honestly? it's giving warning label for a reason π
β¨ SYNOPSIS β¨
# please use Email::MIME::Kit or Catalyst::View::Email::Template instead
use Catalyst 'Email';
__PACKAGE__->config->{email} = [qw/SMTP smtp.oook.de/];
$c->email(
header => [
From => 'sri@oook.de',
To => 'sri@cpan.org',
Subject => 'Hello!'
],
body => 'Hello sri'
);
like, look at that. config goes in, email goes out. slay π
π¦ DESCRIPTION π¦
Send emails with Catalyst and Email::Send and Email::MIME::Creator. that's the whole description bestie, no cap π
π CONFIGURATION π
config accepts the same options as Email::Send. periodt.
To send using the system's sendmail program, set config like so:
__PACKAGE__->config->{email} = ['Sendmail'];
To send using authenticated SMTP:
__PACKAGE__->config->{email} = [
'SMTP',
'smtp.myhost.com',
username => $USERNAME,
password => $PASSWORD,
];
look at her, sending with auth. main character energy honestly π
For different methods of sending emails, and appropriate config options, see Email::Send::NNTP, Email::Send::Qmail, Email::Send::SMTP and Email::Send::Sendmail. like there's a whole little family of them, go say hi π
π METHODS π
email() accepts the same arguments as Email::MIME::Creator's create().
$c->email(
header => [
To => 'me@localhost',
Subject => 'A TT Email',
],
body => $c->subreq( '/render_email' ),
);
To send a multipart message, include a parts argument containing an arrayref of Email::MIME objects.
my @parts = (
Email::MIME->create(
attributes => {
content_type => 'application/pdf',
encoding => 'quoted-printable',
name => 'report.pdf',
},
body => $FILE_DATA,
),
Email::MIME->create(
attributes => {
content_type => 'text/plain',
disposition => 'attachment',
charset => 'US-ASCII',
},
body => $c->subreq( '/render_email' ),
),
);
$c->email(
header => [
To => 'me@localhost',
Subject => 'A TT Email',
],
parts => \@parts,
);
multipart emails?? she contains multitudes π«Ά
π USING WITH A VIEW π
A common practice is to handle emails using the same template language used for HTML pages. If your view supports the 'render' method (Like the TT view does), you just set the body like this:
$c->email(
header => [
To => 'me@localhost',
Subject => 'A TT Email',
],
body => $c->view('TT')->render($c,'mytemplate.tt'),
)
If your view doesn't support render, you can just forward to it, then reset the body like this:
sub send_email : Local {
my ( $self, $c ) = @_;
{
local $c->stash->{names} = [ qw/andyg sri mst/ ],
local $c->stash->{template}= 'mytemplate.tt';
$c->forward($c->view('MyView'));
$c->email(
header => [
To => 'me@localhost',
Subject => 'A TT Email',
],
body => $c->res->body,
);
$c->res->body(undef);
}
}
And the template:
[%- FOREACH name IN names -%]
Hi, [% name %]!
[%- END -%]
--
Regards,
Us
Output:
Hi, andyg!
Hi, sri!
Hi, mst!
--
Regards,
Us
okay the way this template just loops and greets everybody by name?? it's giving personalized emails, it's giving thoughtful, we're obsessed ππ
β SEE ALSO β
CatalystCatalyst::Plugin::SubRequestEmail::SendEmail::MIME::Creator
π AUTHOR π
Sebastian Riedel, "sri@cpan.org" Andy Grundman Carl Franks Marcus Ramberg "mramberg@cpan.org"
π COPYRIGHT π
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, no skips, no skimming, every single option and example accounted for β
perl v5.42.0 Β· 2025-07-25 Β· Catalyst::Plugin::Email(3) β mwah, drink some water, go read the non-deprecated modules, ily πβ¨π¦
π¦ where this page comes from
- fedora 43: perl-Catalyst-Plugin-Email 0.09-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