Skip to content

Instantly share code, notes, and snippets.

@brandonmwest
Created May 28, 2013 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonmwest/5663960 to your computer and use it in GitHub Desktop.
Save brandonmwest/5663960 to your computer and use it in GitHub Desktop.
sendgrid-perl example
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