Mojoli...eption(3pm)
π Mojolicious::Plugin::MailException π
okay bestie, gather round, because this one is literally the "your app crashed and nobody told you" fixer, and it lives in the User Contributed Perl Documentation corner of the perl world. it's giving emergency group chat for your exceptions. π¨β¨
π NAME π
Mojolicious::Plugin::MailException β a Mojolicious plugin that catches your app's crashes and emails the receipts straight to you. no cap. π
πΈ SYNOPSIS πΈ
here's the whole vibe in one go, copy it exactly, don't be cute with it:
package MyServer;
use Mojo::Base 'Mojolicious';
sub startup {
my ($self) = @_;
$self->plugin(MailException => {
from => 'robot@my.site.com',
to => 'mail1@my.domain.com, mail2@his.domain.com',
subject => 'My site crashed!',
headers => {
'X-MySite' => 'crashed'
},
stack => 10
});
}
β¨ DESCRIPTION β¨
so the tea is: this plugin catches all the exceptions, packs them into an email, and sends them to email. that's it. that's the whole job. main character energy for your error handling. π
and now, the options, bestie, in order, no skips:
fromβ the From-address on the email (default isroot@localhost) π§toβ the To-address(es) on the email (default iswebmaster@localhost)subjectβ the subject line for the crash emailheadersβ a hash of headers you want added onto the mailstackβ how big the stack is in the crash mail. default is20.maildirβ this one saves (stores) the messages in the maildir instead of sending them. why would you want that? because if you catch too many crashes, sending them all is probably eating way too much CPU π so with this option you just stash your messages instead of yeeting them out. > heads up bestie: this option gets ignored if the"send"option is defined. periodt.sendβ a subroutine you can use to send the mail yourself. example:
sub startup {
my ($self) = @_;
$self->plugin(MailException => {
send => sub {
my ($mail, $exception) = @_;
$mail->send; # prepared MIME::Lite object
}
});
}
inside that function you can send the email by yourself and (or) prepare and send your own mail (sms, etc) message using the $exception object. go look at Mojo::Exception for that. π¦
the plugin also hands you an extra method (a helper) called mail_exception:
$cx->mail_exception('my_error', { 'X-Add-Header' => 'value' });
you can use that helper to raise an exception with extra mail headers attached. iconic. π
π VCS π
the plugin is placed on github at <https://github.com/dr-co/libmojolicious-plugin-mail_exception> π«Ά
π COPYRIGHT AND LICENCE π
Copyright (C) 2012 by Dmitry E. Oboukhov <unera@debian.org>
Copyright (C) 2012 by Roman V. Nikolaev <rshadow@rambler.ru>
this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. slay. π
and that's the whole page, bestie! this one came from perl v5.40.1, dated 2025-09-24, filed under Mojoli...eption(3pm) in the User Contributed Perl Documentation set. mwah, go forth and get emailed about your crashes. πβ¨
π¦ where this page comes from
- ubuntu resolute: libmojolicious-plugin-mailexception-perl 0.24-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmojolicious-plugin-mailexception-perl 0.24-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms