NAME

Mail::SendGrid - interface to SendGrid.com mail gateway APIs

VERSION

version 0.09

SYNOPSIS

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 => 'neilb@cpan.org');

DESCRIPTION

This module provides easy access to the APIs provided by sendgrid.com, 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.

METHODS

new

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".

  • start_date

  • end_date

  • type

  • email

To delete all bounces, call this without any options:

$sendgrid->delete_bounces();

SEE ALSO

Mail::SendGrid::Bounce

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

SendGrid API documentation

http://sendgrid.com/docs/API%20Reference/Web%20API/bounces.html

REPOSITORY

https://github.com/neilb/Mail-SendGrid

AUTHOR

Neil Bowers <neilb@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Neil Bowers <neilb@cpan.org>.

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