1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| use warnings;
use strict;
use Mail::SendGrid;
use Mail::SendGrid::Transport::SMTP;
my $sg = Mail::SendGrid->new( from => 'from@example.com',
to => 'to@example.com',
subject => 'Testing',
text => "Some text http://sendgrid.com/\n",
html => '<html><body>Some html
<a href="http://sendgrid.com">SG</a>
</body></html>' );
#disable click tracking filter for this request
$sg->disableClickTracking();
#turn on the unsubscribe filter here with custom values
$sg->enableUnsubscribe( text => "Unsubscribe here: <% %>", html => "Unsubscribe <% here %>" );
#set a category
$sg->header->setCategory('first contact');
#add unique arguments
$sg->header->addUniqueIdentifier( customer => '12345', location => 'somewhere' );
my $trans = Mail::SendGrid::Transport::SMTP->new( username => 'sendgrid_username', password => 'sendgrid_password' );
my $error = $trans->deliver($sg);
die $error if ( $error );
|