Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mark mails in Gmail as 'read' and Delete them using Mail::Webmail::Gmail, using Perl script?

Tags:

perl

gmail-api

Using Perl , I need to read mails in Gmail, mark them as 'read' and delete them.

I have tried the below code as given in http://search.cpan.org/dist/Mail-Webmail-Gmail/lib/Mail/Webmail/Gmail.pm

use Mail::Webmail::Gmail;
use Data::Dumper;

my $gmail = Mail::Webmail::Gmail->new(
  username => '[email protected]', password => 'password',
);
print Dumper $gmail;

my @labels = $gmail->get_labels();
print Dumper @labels;

my $messages = $gmail->get_messages( label => $labels[0] );
print Dumper $messages;

Not able to get the labels, messages. What is missing here ?

Is there any other way I could achieve these tasks in Perl.

Thanks in advance. Subhash

like image 735
Subhash Avatar asked Jan 27 '26 13:01

Subhash


1 Answers

That module was last updated in 2006 and the documentation says:

Because Gmail is currently in Beta testing, expect this module to break as they make updates to thier interface. I will attempt to keep this module in line with the changes they make, but, if after updating to the newest version of this module, the feature that you require still doesn't work, please contact me with the issue.

You could try contacting the author, but with ten years since the last release, it looks like he lost interest.

But GMail has an IMAP interface. So you should be able to do what you want with a module like Mail::IMAPClient.

like image 195
Dave Cross Avatar answered Jan 31 '26 04:01

Dave Cross



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!