_prepare_content($option__values) : \@content
Given a $option__values hashref, transform it to an arrayref suitable for sending as multipart/form-data. The core logic here is that array references are modified from:
option => [ value1, value2, ... ]
to
[ option => value1, option => value2, ... ]
NAME
WWW::Mailgun - Perl wrapper for Mailgun (http://mailgun.org)
SYNOPSIS
use WWW::Mailgun;
my $mg = WWW::Mailgun->new({
key => 'key-yOuRapiKeY',
domain => 'YourDomain.mailgun.org',
from => 'elb0w <elb0w@YourDomain.mailgun.org>' # Optionally set here, you can set it when you send
});
#sending examples below
# Get stats http://documentation.mailgun.net/api-stats.html
my $obj = $mg->stats;
# Get logs http://documentation.mailgun.net/api-logs.html
my $obj = $mg->logs;
DESCRIPTION
Mailgun is a email service which provides email over a http restful API. These bindings goal is to create a perl interface which allows you to easily leverage it.
USAGE
new({key => 'mailgun key', domain => 'your mailgun domain', from => 'optional from')
Creates your mailgun object
from => the only optional field, it can be set in the message.
send($data)
Send takes in a hash of settings Takes all specificed here http://documentation.mailgun.net/api-sending.html 'from' is optionally set here, otherwise you can set it in the constructor and it can be used for everything
- Send a HTML message with optional array of attachments
-
$mg->send({ to => 'some_email@gmail.com', subject => 'hello', html => '<html><h3>hello</h3><strong>world</strong></html>', attachment => ['/Users/elb0w/GIT/Personal/Mailgun/test.pl'] });
- Send a text message
-
$mg->send({ to => 'some_email@gmail.com', subject => 'hello', text => 'Hello there' });
- Send a MIME multipart message
-
$mg->send({ to => 'some_email@gmail.com', subject => 'hello', text => 'Hello there', html => '<b>Hello there</b>' });
unsubscribes, bounces, spam
Helper methods all take a method argument (del, post, get) http://documentation.mailgun.net/api_reference.html 'post' optionally takes a hash of properties
- Unsubscribes
-
# View all unsubscribes L<http://documentation.mailgun.net/api-unsubscribes.html> my $all = $mg->unsubscribes; # Unsubscribe user from all $mg->unsubscribes('post',{address => 'user@website.com', tag => '*'}); # Delete a user from unsubscriptions $mg->unsubscribes('del','user@website.com'); # Get a user from unsubscriptions $mg->unsubscribes('get','user@website.com');
- Complaints
-
# View all spam complaints L<http://documentation.mailgun.net/api-complaints.html> my $all = $mg->complaints; # Add a spam complaint for a address $mg->complaints('post',{address => 'user@website.com'}); # Remove a complaint $mg->complaints('del','user@website.com'); # Get a complaint for a adress $mg->complaints('get','user@website.com');
- Bounces
-
# View the list of bounces L<http://documentation.mailgun.net/api-bounces.html> my $all = $mg->bounces; # Add a permanent bounce $mg->bounces('post',{ address => 'user@website.com', code => 550, #This is default error => 'Error Description' #Empty by default }); # Remove a bounce $mg->bounces('del','user@website.com'); # Get a bounce for a specific address $mg->bounces('get','user@website.com');
TODO
Author
George Tsafas <elb0w@elbowrage.com>
Support
elb0w on irc.freenode.net #perl https://github.com/gtsafas/mailgun.perl
Resources
http://documentation.mailgun.net/
6 POD Errors
The following errors were encountered while parsing the POD:
- Around line 257:
'=item' outside of any '=over'
- Around line 284:
You forgot a '=back' before '=head2'
- Around line 291:
'=item' outside of any '=over'
- Around line 339:
You forgot a '=back' before '=head1'
- Around line 341:
'=item' outside of any '=over'
- Around line 349:
You forgot a '=back' before '=head1'