This worked fine, WWW::Mechanize, LWP::UserAgent, and JSON to handle the messages from the API. You will have to put in your own valid ids etc. The ones below are randomized/edited.

use strictures; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); $mech->credentials( api => "key-da0f99505ece11e48064d6516832a126" ); $mech->post( "https://api.mailgun.net/v2/xyz.mailgun.org/messages", [ from => 'Mailgun Sandbox <postmaster@sandboxyz.mailgun. +org>', to => 'Kitty <fluffy@cats.co.uk.jp.org>', subject => 'OHAI', text => 'Congratulations! You are a winner. A loser no +more!!' ]); print $mech->response->as_string, $/;
{ "message": "Queued. Thank you.", "id": "<20141028181741.33218.21053@sandboxyz.mailgun.org>" }

First principles, I really recommend against cut and paste programming. You have to know what everything does or you might do something dangerous and you will certainly waste time treating each script as a mystical invocation.

I also think you should have included the real service and such in your original question to make it easier. Not that it was hard to find but if you want help, lowering the bar to do so is often the difference between an answer in 30 minutes and an answer never.


In reply to Re: Curl usage with Perl's system command by Your Mother
in thread Curl usage with Perl's system command by perlron

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.