| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::SendEmail 0.02; |
|
2
|
5
|
|
|
5
|
|
4996752
|
use v5.26; |
|
|
5
|
|
|
|
|
25
|
|
|
3
|
5
|
|
|
5
|
|
38
|
use warnings; |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
454
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Easily send emails from Mojolicious applications |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=encoding utf-8 |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Mojolicious::Plugin::SendEmail - Easily send emails from Mojolicious applications |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Inspired by both L and L |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Register plugin |
|
18
|
|
|
|
|
|
|
$self->plugin('SendEmail' => { |
|
19
|
|
|
|
|
|
|
from => '"My Application" ', |
|
20
|
|
|
|
|
|
|
host => ..., |
|
21
|
|
|
|
|
|
|
port => ..., |
|
22
|
|
|
|
|
|
|
recipient_resolver => sub { ... }, |
|
23
|
|
|
|
|
|
|
... |
|
24
|
|
|
|
|
|
|
}); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
... |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Send simple email |
|
29
|
|
|
|
|
|
|
$c->send_email( |
|
30
|
|
|
|
|
|
|
to => 'mark@tyrrminal.dev', |
|
31
|
|
|
|
|
|
|
subject => "Alert: MyApp failure", |
|
32
|
|
|
|
|
|
|
body => "An error occurred when processing nightly data" |
|
33
|
|
|
|
|
|
|
); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
... |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Send template-based email with attachments |
|
38
|
|
|
|
|
|
|
$c->send_email( |
|
39
|
|
|
|
|
|
|
to => 'daily', |
|
40
|
|
|
|
|
|
|
subject => 'Nightly Attendance Report', |
|
41
|
|
|
|
|
|
|
template => 'reports/nightly_attendance', |
|
42
|
|
|
|
|
|
|
params => { |
|
43
|
|
|
|
|
|
|
data => $report_data |
|
44
|
|
|
|
|
|
|
}, |
|
45
|
|
|
|
|
|
|
files => ['generated/Nightly_Attendance_Report.xlsx'] |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Mojolicious::Plugin::SendEmail is a convenient wrapper for L and |
|
51
|
|
|
|
|
|
|
L for sending email from Mojolicious commands |
|
52
|
|
|
|
|
|
|
and controllers, etc. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
The basic concept here is that it sets up the SMTP details at initial plugin load |
|
55
|
|
|
|
|
|
|
and then every subsequent call to L or L uses those |
|
56
|
|
|
|
|
|
|
values, so that subsequently you don't need to worry about them. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
A little bit of "added value" functionality exists in this module as well: |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=over |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item * Unlike L you I don't need to tell it whether |
|
63
|
|
|
|
|
|
|
your body is text or HTML. See L |