View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Neil Bowers > Mail-SendGrid > Mail::SendGrid



Annotate this POD


View/Report Bugs
Module Version: 0.09   Source  


Mail::SendGrid - interface to mail gateway APIs


version 0.09


 use Mail::SendGrid;
 $sendgrid = Mail::SendGrid->new('api_user' => '...', 'api_key' => '...');
 print "Email to the following addresses bounced:\n";
 foreach my $bounce ($sendgrid->bounces) {
     print "\t", $bounce->email, "\n";
 $sendgrid->delete_bounces(email => '');


This module provides easy access to the APIs provided by, a service for sending emails. At the moment the module just provides the bounces() and delete_bounces() methods. Over time I'll add more of the SendGrid API.



Takes two parameters, api_user and api_key, which were specified when you registered your account with SendGrid. These are required.

bounces ( %params )

This requests bounces from SendGrid, and returns a list of Mail::SendGrid::Bounce objects. By default it will pull back all bounces, but you can use the following parameters to constrain which bounces are returned:

days => N

Number of days in the past for which to return bounces. Today counts as the first day.

start_date => 'YYYY-MM-DD'

The start of the date range for which to retrieve bounces. The date must be in ISO 8601 date format.

end_date => 'YYYY-MM-DD'

The end of the date range for which to retrieve bounces. The date must be in ISO 8601 date format.

limit => N

The maximum number of bounces that should be returned.

offset => N

An offset into the list of bounces.

type => 'hard' | 'soft'

Limit the returns to either hard or soft bounces. A soft bounce is one which would have a 4xx SMTP status code, a persistent transient failure. A hard bounce is one which would have a 5xx SMTP status code, or a permanent failure.

email => 'email-address'

Only return bounces for the specified email address.

For example, to get a list of all soft bounces over the last week, you would use:

  @bounces = $sendgrid->bounces(type => 'soft', days => 7);

delete_bounces( %options )

This is used to delete one or more bounces, or even all bounces; the following options constrain which bounces are deleted. For a description of the options, see "bounces".

To delete all bounces, call this without any options:




The class which defines the data objects returned by the bounces method.

SendGrid API documentation



Neil Bowers <>


This software is copyright (c) 2012 by Neil Bowers <>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: