GMail::Checker - Wrapper for Gmail accounts
version 1.00
use GMail::Checker; my $gwrapper = new GMail::Checker(); my $gwrapper = new GMail::Checker(USERNAME => "username, PASSWORD => "password"); # Let's log into our account (using SSL) $gwrapper->login("username","password"); # Get the number of messages in the maildrop & their total size my ($nb, $size) = $gwrapper->get_msg_nb_size(); # Do we have new messages ? my $alert = $gwrapper->get_pretty_nb_messages(ALERT => "TOTAL_MSG"); # Get the headers for a specific message (defaults to last message) my @headers = $gwrapper->get_msg_headers(HEADERS => "FULL", MSG => 74); # Get a message size my ($msgnb, $msgsize) = $gwrapper->get_msg_size(MSG => 42); # Retrieve a specific message my @msg = $gwrapper->get_msg(MSG => 23); # Retrieve UIDL for a message my @uidl = $gwrapper->get_uidl(MSG => 10);
This module provides a wrapper that allows you to perform major operations on your gmail account.
You may create a notifier to know about new incoming messages, get information about a specific e-mail,
retrieve your mails using the POP3 via SSL interface.
The implemented methods are :
Creates the wrapper object.
The IO::Socket::SSL object is stored as $object->{SOCK}.
It currently only accepts username and password as hash options.
USERNAME
Your GMail account username (without @gmail.com).
PASSWORD
Your GMail password.
get_msg_nb_size
This method checks your maildrop for the number of messages it actually contains and their total size.
It returns an array which consists of (message_numbers, total_size).
Example :
my ($msgnb, $size) = $gwrapper->get_msg_nb_size(); or my @maildrop = $gwrapper->get_msg_nb_size();
get_pretty_nb_messages
Alerts you when you have new mails in your mailbox.
It takes as a hash argument ALERT which can have two values :
NEW_MSG_ONLY
Gives you only the number of new messages that have arrived in your mailbox since the last check.
TOTAL_MSG
Gives you the total number of messages and the actual size of the mailbox prettily formatted.
get_msg_size
This methods retrieves the messages size.
By default, it will return an array containing all the messages with message number and its size.
Given the hash argument MSG, size information will be returned for that message only.
Returns (-1,-1) if the mailbox is empty.
my @msg_sizes = $gwrapper->get_msg_size(); foreach $a (@msg_sizes) { print "Message number %d - size : %d", $a->{nb>, $a->{size}; } my @specific_msg_size = $gwrapper->get_msg_size(MSG => 2); printf "Message number %d - size : %d", $specific_msg_size[0]->{nb>, $specific_msg_size[0]->{size};
get_msg
Retrieves a message from your mailbox and returns it as an array.
If no message number is specified, it will retrieve all the mails in the mailbox.
Returns an empty array if there is no message matching the request or mailbox is empty.
The method accepts as hash arguments :
MSG
The message number
DELETE
Deletes the message from the server
By default the messages are kept in the mailbox.
Do not forget to specify what happens to the mails that have been popped in your Gmail account settings.
my @msg = $gwrapper->get_msg(MSG => 2, DELETE => 1); print $msg[0]->{headers}, $msg[0]->{body};
In case all messages are returned, just loop over the array to get them.
get_msg_headers
Retrieves a message header and returns them as an array (one header item per line).
If no message number is specified, the last message headers will be retrieved.
The function takes two type of arguments as hashes
HEADERS
Takes two values, FULL for full headers and MINIMAL for From, Subject and Date only.
my @headers = $gwrapper->get_msg_headers(HEADERS => "FULL", MSG => 3); foreach $h (@headers) { print $h; }
get_uidl
Gets messages UIDL (unique-Id [hash] attributed to the message by the server).
Takes as a hash argument the MSG number or retrieves the UIDLs for all the messages.
my @uidls = $gwrapper->get_uidl(); foreach $uid (@uidls) { print $uid->{nb}, " ", $uid->{hash}; } my $spec_uid = $gwrapper->get_uidl(MSG => 1);
rset
If any messages have been marked as deleted by the POP3 server, they are unmarked.
close
Closes the connection after sending a QUIT command so the server properly switches to the UPDATE state.
It doesn't take any argument for now.
1.00
Copyright 2004 by Faycal Chraibi. All rights reserved.
This library is a free software. You can redistribute it and/or modify it under the same terms as Perl itself.
Faycal Chraibi <fays@cpan.org>
- Include charsets conversions support
- Search through mails and headers
- Include mail storing/reading option
- Headers regexp argument for headers retrieval
- Correct bugs ?
IO::Socket::SSL, WWW::GMail
5 POD Errors
The following errors were encountered while parsing the POD:
=back doesn't take any parameters, but you said =back 4
To install GMail::Checker, copy and paste the appropriate command in to your terminal.
cpanm
cpanm GMail::Checker
CPAN shell
perl -MCPAN -e shell install GMail::Checker
For more information on module installation, please visit the detailed CPAN module installation guide.