A popular mail blasting service does not have a perl api, but thankfully has a curl one i can use :D
My difficulty is in composing the multiline format string that will constitute the mail message.
Ive put together the code and it works as such, but unfortunately one area i am still not getting is adding multiple lines to the message in a clean and efficient manner.
The system command usage is not working with me when i try to passing strings to it as an array argument?
how can i debug / solve this ?
I even tried shell quotes as a monk corrected earlier
here, but i still dont get the hang of what is going wrong .
#!/usr/bin/perl
use Capture::Tiny qw/ capture /;
use String::ShellQuote;
my ($stdout,$stderr,$exit) = capture {
my $command = " curl -s --user \'api:key*****\'";
$command .= " https://api.****/**/*****/messages";
$command .= " -F from='*****'";
$command .= " -F to=\'Name <$to_id>\'";
$command .= " -F subject=\'$subject\'";
$command .= " -F text=\'$message\'";
my $message = " -F text=\'test a new line\'";
@args = ($message);
#this works
system $command ;
#this doesnt. result is -1
system $command @args;
#this doesnt either. result is -1
system $command shell_quote @args
};
print $stdout,$stderr,$exit;
Do not wait to strike when the iron is hot! Make it hot by striking - WB Yeats
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.