Created
May 28, 2013 16:16
-
-
Save brandonmwest/5663960 to your computer and use it in GitHub Desktop.
sendgrid-perl example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment