Coder Social home page Coder Social logo

mailgun.perl's Introduction

WWW::Mailgun

Perl wrapper for Mailgun (http://mailgun.org)

SYNOPSIS

use Mailgun;

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.

use WWW::Mailgun;

my $mg = WWW::Mailgun->new({ 
    key => 'key-yOuRapiKeY',
    domain => 'YourDomain.mailgun.org',
    from => 'elb0w <[email protected]>' # Optionally set here, you can set it when you send
});

# 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; 

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 an attachment using a filename
$mg->send({
      to => '[email protected]',
      subject => 'hello',
      html => '<html><h3>hello</h3><strong>world</strong></html>',
      attachment => ['/Users/elb0w/GIT/Personal/Mailgun/test.pl']
});
Send a HTML message with an attachment using raw data
$mg->send({
      to => '[email protected]',
      subject => 'hello',
      html => '<html><h3>hello</h3><strong>world</strong></html>',
      attachment => [ undef, 'something.txt', 'Hello from inside the file' ],
});

Send a HTML message with multiple attachments

$mg->send({
      to => '[email protected]',
      subject => 'hello',
      html => '<html><h3>hello</h3><strong>world</strong></html>',
      attachments => [
            [ '/Users/elb0w/GIT/Personal/Mailgun/test.pl' ],
            [ undef, 'something.txt', 'Hello from inside the file' ],
      ],
});
Send a text message
$mg->send({
      to => '[email protected]',
      subject => 'hello',
      text => 'Hello there',
});
Send a MIME multipart message
$mg->send({
      to      => '[email protected]',
      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 http://documentation.mailgun.net/api-unsubscribes.html
my $all = $mg->unsubscribes; 

# Unsubscribe user from all 
$mg->unsubscribes('post',{address => '[email protected]', tag => '*'});

# Delete a user from unsubscriptions
$mg->unsubscribes('del','[email protected]');

# Get a user from unsubscriptions
$mg->unsubscribes('get','[email protected]');
Complaints
# View all spam complaints http://documentation.mailgun.net/api-complaints.html
my $all = $mg->complaints; 

# Add a spam complaint for a address
$mg->complaints('post',{address => '[email protected]'});

# Remove a complaint
$mg->complaints('del','[email protected]');

# Get a complaint for a adress
$mg->complaints('get','[email protected]');
Bounces
# View the list of bounces http://documentation.mailgun.net/api-bounces.html
my $all = $mg->bounces; 

# Add a permanent bounce
$mg->bounces('post',{
    address => '[email protected]',
    code => 550, #This is default
    error => 'Error Description' #Empty by default
});

# Remove a bounce
$mg->bounces('del','[email protected]');

# Get a bounce for a specific address
$mg->bounces('get','[email protected]');

TODO

Mailboxes Campaigns Mailing Lists Routes

--Add Moose version

Author

George Tsafas [email protected]

Support

elb0w on irc.freenode.net #perl

Resources

http://documentation.mailgun.net/

mailgun.perl's People

Contributors

gtsafas avatar spiros avatar

Watchers

James Cloos avatar Jack avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.