Net::Postage::App - Perl extension for Postageapp.com API
use Net::Postage::App; my $postage = Net::Postage::App->new(api_key => 'YOUR_PostageApp_API_KEY_HERE'); ## first - prepare your message $postage->message( from => 'your_name <your_email>', subject => 'Hi This is a test message', textmessage => 'Hi there this is a TEXT message test', htmlmessage => '<b>Hi there this is an HTML message test</b>', reply_to => 'no-reply@example.com', headers => { 'x-mailer' => 'Postage-App.pm' } ); ## second - add recipients ## You can add a single recipient $postage->to('test@example.com'); ## You can add an array of recipients at once $postage->to(['test@example.com','test2@example2.com',...]); ## Or hash of recipients for variable replacement $postage->to({ 'test@example.com' => { first_name => 'Mahmoud', ... }, 'test2@example2.com' => { first_name => 'fName', ... } }); ## Last, do the send $postage->send(); ## make sure the sending was suucessful ## otherwise send again later if (!$postage->is_success){ print $postage->errorMessage . "\n"; } else { print "Your message sent successfully"; }
Perl interface to the Postageapp.com API
postageapp.com "From their website" Outsource the sending of your application generated email, so your app can do what it does best... be awesome!
See http://postageapp.com
my $postageapp = Net::Postage::App->new( api_key => 'YOUR API KEY' )
Create a new message to be sebt later
$postageapp->message( from => 'Joe <joe.something@domain.com>', subject => '...', textmessage => '...' )
message method accepts the following arguments
Required : your from name and email address
Required : your message subject line
Optional if htmlmessage available
Optional if textmessage available, you can provide both fields
Optional : reply to email field
arrayref of files you want to send as an attachment
Optional : When sending a message, a unique hash will be created to prevent resending the same message again, set this to 1 if you want to send the same identical message to same recipients
Optional : name of the template you set at your postageapp dashboard if you set this then there is no need for other headers
Optional : hashref of default variables to be used when recipients info is missing
Optional : hashref of extra headers to include in your email
Where to send your email
to method accepts one of the following
to
a single email address
$postageapp->to('email address');
an arrayref of multi recipients
$postageapp->to(['email1','email2','...']);
hashref of multi recipients with customization fields
{ 'email1' => { 'name' => 'Joe', 'age' => 32, ... }, 'email2' => { 'name' => '', ... } }
to use these fields in your email you need to compose a text/html message in message method by wrapping a word in doubled curly braces like {{name}} and {{age}}
message
send your email
$postageapp->send()
returns true if the send process was successful
if ( $postageapp->is_success ) { }
returns error message if the send process failed
$postageapp->errorMessage()
None by default.
For more information about postageapp API please visit their documentation page http://postageapp.com/docs/api
Mahmoud A Mehyar, <mamod.mehyar@gmail.com<gt>
Copyright (C) 2010-2013 by Mahmoud A. Mehyar
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.
To install Net::Postage::App, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Postage::App
CPAN shell
perl -MCPAN -e shell install Net::Postage::App
For more information on module installation, please visit the detailed CPAN module installation guide.