Mail::IMAP2SMS - Perl extension for IMAP to SMS.
# Import Module use Mail::IMAP2SMS; # Instantiate the IMAP2SMS object. my $sms = Mail::IMAP2SMS->new('imap.example.com', 'test@example.com', 'p4$$w0rd', 1); # Get unseen mail from inbox. my $unseen = $sms->get_unseen('INBOX'); # Chunk each message into specified size (160) SMSs. foreach (@$unseen) { my ($id) = $_; $sms->chunk($id, 160); } # foreach # Send chunked messages. if ($sms->send('7895551234@vtext.com')) { print 'All sent successfully'; } else { print 'Send failed...'; } # if/else # Close connection $sms->disconnect;
This module is a quick and easy way to SMS your IMAP email.
my $sms = Mail::IMAP2SMS->new( $server [ :port ], $username, $password, $ssl );
This class method constructs a Mail::IMAP2SMS object. It takes four required parameters. The server parameter may specify just the
Mail::IMAP2SMS
server, or both the server and the port. To specify an alternate port, seperate it from the server with a colon (:), example.com:9876.
:
example.com:9876
The ssl (BOOLEAN) parameter may specify whether to use or not use SSL to connect to the specified IMAP server.
my $seen = $sms->get_seen('INBOX');
This method takes one required parameter, an IMAP folder. The number of seen messages is returned on success. On failure, nothing is returned.
my $unseen = $sms->get_unseen('INBOX');
print 'Successfully chunked!' if $sms->chunk($id, 160);
This method takes two require parameters, a message ID and a chunking size. The message ID is used to get the message from the IMAP server. Upon getting the message it is determined whether the subject and body can fit in one SMS or if the message must be broken into segments of the proper SMS size. Carriers differ on SMS size thus a size must be specified. On success, boolean true is returned. On failure, nothing is returned.
print 'Send successful...' if $sms->send('7895551234@vtext.com');
This method requires one parameter, a wireless carrier phone number email address. This method will send all SMS created to the specified email address. If more than three SMS are readied to send, a sending sleep time between each SMS will be applied to reduce the chance of the wireless carrier dropping any messages. On success, a boolean true is returned. On failure, nothing is returned.
print 'Disconnected from IMAP...' if $sms->quit;
This method requires no parameters. It simply closes the connection to the IMAP server. On success, a boolean true is returned. On failure, nothing is returned.
Roy Crowder, <roy.crowder@gmail.com>.
Net::IMAP::Simple, Net::IMAP::Simple::SSL, Email::Simple, Mail::Sendmail, perl, Changes
Copyright (c) 2009 Roy Crowder.
All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Mail::IMAP2SMS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mail::IMAP2SMS
CPAN shell
perl -MCPAN -e shell install Mail::IMAP2SMS
For more information on module installation, please visit the detailed CPAN module installation guide.