Mojolicious::Plugin::MailException - Mojolicious plugin to send crash information by email
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 }); }
The plugin catches all exceptions, packs them into email and sends them to email.
There are some plugin options:
From-address for email (default root@localhost)
To-address(es) for email (default webmaster@localhost)
Subject for crash email
Hash with headers that have to be added to mail
Stack size for crash mail. Default is 20.
20
This option saves (stores) messages in the maildir instead of sending them. If you catch too many crashes, then their sending probably uses too much of the CPU, so by using this option you may save your messages instead of sending them.
The option is ignored if send option is defined.
send
Subroutine that can be used to send the mail, example:
sub startup { my ($self) = @_; $self->plugin(MailException => { send => sub { my ($mail, $exception) = @_; $mail->send; # prepared MIME::Lite object } }); }
In the function You can send email by yourself and (or) prepare and send Your own mail (sms, etc) message using $exception object. See Mojo::Exception.
The plugin provides additional method (helper) mail_exception.
$cx->mail_exception('my_error', { 'X-Add-Header' => 'value' });
You can use the helper to raise exception with additional mail headers.
The plugin is placed on github.
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.
To install Mojolicious::Plugin::MailException, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::MailException
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::MailException
For more information on module installation, please visit the detailed CPAN module installation guide.