NAME
GMail::Checker - Wrapper for Gmail accounts
VERSION
1.03
SYNOPSIS
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);
DESCRIPTION
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.
METHODS
The implemented methods are :
new
-
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.
Example :
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.
Example :
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
MSG
-
The message number
HEADERS
-
Takes two values, FULL for full headers and MINIMAL for From, Subject and Date only.
Returns an empty array if there is no message matching the request or mailbox is empty.
Example :
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.
Returns (-1,-1) if the mailbox is empty.
Example :
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.
COPYRIGHT
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.
AUTHOR
Faycal Chraibi <fays@cpan.org>
TODO
- Include charsets conversions support
- Search through mails and headers
- Include mail storing/reading option
- Headers regexp argument for headers retrieval
- Correct bugs ?
SEE ALSO
5 POD Errors
The following errors were encountered while parsing the POD:
- Around line 319:
=back doesn't take any parameters, but you said =back 4
- Around line 350:
=back doesn't take any parameters, but you said =back 4
- Around line 391:
=back doesn't take any parameters, but you said =back 4
- Around line 423:
=back doesn't take any parameters, but you said =back 4
- Around line 459:
=back doesn't take any parameters, but you said =back 4