Available on cpan – Mail::Webmail::Gmail
This module gives the ability to do almost anything with Gmail programmatically through perl.
Thanks for all the hardwork and effort in getting this back up and working! I’ve been swamped and havent been able to do some maintenance on this module in a bit. Hopefully I will be able to incorporate these change into the main tree soon.
April 15th, 2005 at 10:12 am
Very cool! Great work!
April 26th, 2005 at 12:15 pm
Additionally, there’s a python script useful to store files on a Gmail account called “GmailFS” . I tested it on Linux and Windows and found it great. Have a look at http://libgmail.sourceforge.net and http://richard.jones.name/google-hacks/gmail-filesystem/gmail-filesystem.html
May 17th, 2005 at 5:34 pm
This is nice! Would you be willing to incorporate what you have here in a local SMTP server, so one can use his own mail program to send mails through gmail, without having to rely on SMTP? That would be somewhat like whathttp://www.lightningsp.com/modules/mydownloads/singlefile.php?cid=6&lid=8 does, but better… I’m trying to do that because my handheld is connected to a wireless network that only allows proxied HTTP(S) traffic.
August 20th, 2005 at 3:47 pm
Hi there, I made some modification to add a edit_filters method that allows creating filters. Let me know if you want to incorporate this and make an updated release. I can mail you the source I have.
August 29th, 2005 at 8:33 am
Have any users had problems with the DOS attack protection? I debugged the module and found out that I was being challenged to interpret an automatically generated image. I would like to patch this, as I can’t use the module without it, but before I do, I’m just wondering if (a) anybody else has had this problem and (b) whether the error handling in the login method needs to be generalized
September 10th, 2005 at 6:10 pm
Is anyone seen that module not working now ? I tested it with the example script and correct credentials, without success.
Julien
September 11th, 2005 at 12:53 am
It seems something has changed at the Gmail end, because as from September 9th the Mail::Webmail::Gmail module is no longer working.
September 11th, 2005 at 5:32 am
In fact, cookie are not forwarded from the first GET http://mail.google.com/mail to the GET https://www.google.com/accounts/...
I checked in the LWP::UserAgent code, in the request sub. In fact, that is normal, the following code comes from it :
# These headers should never be forwarded
$referral->remove_header(‘Host’); ‘Cookie’);
Dont’ know why, as I’m no HTTP header expert.
To be sure, I changed the LWP::UserAgent code (!) to make Cookie header be forwarded and … that worked.
Any hint ?
Kind regards
Julien
September 12th, 2005 at 8:56 am
Hi Julien,
I also use Mail::Webmail::Gmail to send mail and it stopped working a few days ago. I have no idea how to fix it, as I am nor a web neither a perl programmer, but I would like to have a workaround if possible. Can you please send me the changes you made to UserAgent.pm to make it work? I tried to comment out the line you mentioned, but it didn’t work — probably there is more than just commenting out that line.
Thanks.
September 12th, 2005 at 3:31 pm
Hi
I made another comment about the other things I did, but it is still awaiting moderation. I think it was too long… Anyway, I posted the Gmail.pm I use here :
http://www.greyhats.org/files/Gmail.pm
Moreover, the only change I made in UserAgent.pm (from LWP) is replacing, in the request sub, the line
$referral->remove_header(‘Host’), ‘Cookie’);
by
$referral->remove_header(‘Host’); #, ‘Cookie’);
Warning : This is dirty hack, very dirty hack…
Julien
September 13th, 2005 at 4:26 am
Hi Julien,
many thanks for the answer — it works now.
Thanh
September 13th, 2005 at 10:15 am
Hi Julien,
I did modify the UserAgent.pm and also using Julien’s Gmail.pm. Still I’, not able to login.
I ran the perl -d and found out that its failing at
110: if ( $res->content() =~ // ) {
DB
Mail::Webmail::Gmail::login(/usr/lib/perl5/site_perl/5.6.0/Mail/Webmail/Gmail.pm:126):
126: $self->{_error} = 1;
Thanks
Mudit
September 13th, 2005 at 10:18 am
Nevermind .. false alarm ..
its working now !!!!
[I had written a request_hack function in UserAgent which has your modifications, but I forgot to call it when I copied your Gmail.pm file and overwrote my changes].
Thanks !!
Mudit
October 4th, 2005 at 3:21 am
hi, Julien,
Another question, I am using this model to delete those thousands trash mail. After delete about 60 trash emails, it seems gmail has blocked my account and the perl code does not work on the trash mail, althoug the print information shows it is still working. but the amount of trash email stopped decrease. and after I runned the perl script sereval time, gmail show this message,
Our system indicates unusual usage of your account. In order to protect Gmail users from potentially harmful use of Gmail, this account has been disabled for up to 24 hours.
Any comments?
thanks.
March 26th, 2006 at 4:18 am
Thanks!
This is one of the most useful modules ever. It really helped me a lot!
September 10th, 2006 at 11:28 am
How do I retrieve ALL the messages in a conversation? It seems the examples only return the last message in a thread/conversation. Is there a way to return all individual emails?
Otherwise, it’s a very nice implementation. Thanks!
December 9th, 2006 at 7:27 pm
Example Script (after much more code reading):
This script prints the individual messages in a thread/conversation:
my $threads = $gmail->get_messages( label => ‘perl-test-label’ );
foreach ( @{ $threads } ) {
my $thread = $gmail->get_indv_email( msg => $_ );
foreach $messageid ( sort keys %{$thread}) {
my $body = $gmail->get_mime_email( id => $messageid , label => ‘perl-test-label’ );
print $body;
};
};
The key to this is the function get_mime_email – though this basically is the same as the gmail function ‘Show original message’
I hope this helps people.
Best Regards.