Perl module for SendGrid's API
Perl Perl6
Latest commit 77553bf Apr 27, 2016 @thinkingserious thinkingserious Update


As of May 1, 2016, SendGrid will no longer support this library.

Please direct any questions to the Developer Experience team.

Build Status


Send emails via SendGrid. Provides wrapper for custom SMTP API fields and allows for easy manipulation of filter/app settings.

Written by Tim Jenkins.


Licensed under the MIT License.


We are currently working on getting this module on CPAN. In the meantime, you can install from the included archive.

git clone
cd sendgrid-perl
sudo cpanm SendGrid-1.3.tar.gz

You can also build the archive yourself:

perl Makefile.PL
make test
make dist

Basic usage

For authentication, please use either your SendGrid credentials or an API key.

use warnings;
use strict;

use Email::SendGrid;
use Email::SendGrid::Transport::REST;

my $sg = Email::SendGrid->new( from => '',
                              to => '',
                              subject => 'Testing',
                              text => "Some text\n",
                              html => '<html><body>Some html
                                                  <a href="">SG</a>
                                       </body></html>' );

#disable click tracking filter for this request

#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 = Email::SendGrid::Transport::REST->new( username => 'sendgrid_username', password => 'sendgrid_password' );

my $error = $trans->deliver($sg);
die $error if ( $error );

Advanced Usage

For more detailed information, please refer to the perldocs.