The Perl Advent Calendar needs more articles for 2022. Submit your idea today!

_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, ... ]


    [ option => value1, option => value2, ... ]


WWW::Mailgun - Perl wrapper for Mailgun (


    use WWW::Mailgun;

    my $mg = WWW::Mailgun->new({
        key => 'key-yOuRapiKeY',
        domain => '',
        from => 'elb0w <>' # Optionally set here, you can set it when you send

    #sending examples below

    # Get stats
    my $obj = $mg->stats;

    # Get logs
    my $obj = $mg->logs;


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.


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 takes in a hash of settings Takes all specificed here '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
          to => '',
          subject => 'hello',
          html => '<html><h3>hello</h3><strong>world</strong></html>',
          attachment => ['/Users/elb0w/GIT/Personal/Mailgun/']
Send a text message
          to => '',
          subject => 'hello',
          text => 'Hello there'
Send a MIME multipart message
          to      => '',
          subject => 'hello',
          text    => 'Hello there',
          html    => '<b>Hello there</b>'

unsubscribes, bounces, spam

Helper methods all take a method argument (del, post, get) 'post' optionally takes a hash of properties

    # View all unsubscribes L<>
    my $all = $mg->unsubscribes;

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

    # Delete a user from unsubscriptions

    # Get a user from unsubscriptions
    # View all spam complaints L<>
    my $all = $mg->complaints;

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

    # Remove a complaint

    # Get a complaint for a adress
    # View the list of bounces L<>
    my $all = $mg->bounces;

    # Add a permanent bounce
        address => '',
        code => 550, #This is default
        error => 'Error Description' #Empty by default

    # Remove a bounce

    # Get a bounce for a specific address


Mailing Lists


George Tsafas <>


elb0w on #perl


6 POD Errors

The following errors were encountered while parsing the POD:

Around line 259:

'=item' outside of any '=over'

Around line 286:

You forgot a '=back' before '=head2'

Around line 293:

'=item' outside of any '=over'

Around line 341:

You forgot a '=back' before '=head1'

Around line 343:

'=item' outside of any '=over'

Around line 351:

You forgot a '=back' before '=head1'