| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mojo::Sendgrid; |
|
2
|
1
|
|
|
1
|
|
304590
|
use Mojo::Base 'Mojo::EventEmitter'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
501
|
use Mojo::Sendgrid::Mail; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has config => sub { {} }; |
|
9
|
|
|
|
|
|
|
has apikey => sub { $ENV{SENDGRID_APIKEY} || shift->config->{apikey} or die "config apikey missing" }; |
|
10
|
|
|
|
|
|
|
has apiurl => sub { $ENV{SENDGRID_APIURL} || shift->config->{apiurl} || 'https://api.sendgrid.com/api/mail.send.json' }; |
|
11
|
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
1
|
11957
|
sub mail { Mojo::Sendgrid::Mail->new(sendgrid => shift, @_) } |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
1; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=encoding utf8 |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Mojo::Sendgrid - Sendgrid API implementation for the Mojolicious framework |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 VERSION |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
0.02 |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use Mojo::Sendgrid; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $sendgrid = Mojo::Sendgrid->new( |
|
31
|
|
|
|
|
|
|
config => { |
|
32
|
|
|
|
|
|
|
apikey => 'get your key from api.sendgrid.com', |
|
33
|
|
|
|
|
|
|
#apiurl => 'you do not need to set this', |
|
34
|
|
|
|
|
|
|
}, |
|
35
|
|
|
|
|
|
|
); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$sendgrid->on(mail_send => sub { |
|
38
|
|
|
|
|
|
|
my ($sendgrid, $ua, $tx) = @_; |
|
39
|
|
|
|
|
|
|
say $tx->res->body; |
|
40
|
|
|
|
|
|
|
}); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
say $sendgrid->mail( |
|
43
|
|
|
|
|
|
|
to => q(a@b.com), |
|
44
|
|
|
|
|
|
|
from => q(x@y.com), |
|
45
|
|
|
|
|
|
|
subject => time, |
|
46
|
|
|
|
|
|
|
text => time |
|
47
|
|
|
|
|
|
|
)->send; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Mojo::IOLoop->start; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
L is an implementation of the Sendgrid API and is non-blocking |
|
54
|
|
|
|
|
|
|
thanks to L from the wonderful L framework. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
It currently implements the mail endpoint of the Web API v2. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This class inherits from L. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 EVENTS |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Mojo::Sendgrid inherits all events from Mojo::EventEmitter and can emit the following new ones. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 mail_* |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
See for full list |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 config |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Holds the configuration hash. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 apikey |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Accesses the apikey element of L. |
|
77
|
|
|
|
|
|
|
Can be overridden by the environment variable SENDGRID_APIKEY. |
|
78
|
|
|
|
|
|
|
This attribute is required to have a value. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 apiurl |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Accesses the apiurl element of L. |
|
83
|
|
|
|
|
|
|
Can be overridden by the environment variable SENDGRID_APIURL. |
|
84
|
|
|
|
|
|
|
This attribute by default uses the Web API v2 URL documented by Sendgrid. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 METHODS |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 mail |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
$self = $self->mail(%args); |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
The mail endpoint of the Sendgrid Web API v2. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
|
97
|
|
|
|
|
|
|
the terms of the Artistic License version 2.0. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 AUTHOR |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Stefan Adams - C |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |