Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- # @kaiux
- use IMAP::Client;
- use Data::Dumper;
- use strict;
- use warnings;
- my $server = 'imap.server.com';
- my $user = 'user@domain';
- my $pass = 'YourStrongPass';
- my $imap = new IMAP::Client();
- $imap->connect(
- PeerAddr => $server,
- ConnectMethod => 'SSL STARTTLS PLAIN',
- )
- or die "Unable to connect to [$server]: ".$imap->error();
- $imap->onfail('ERROR');
- $imap->errorstyle('STACK');
- #$imap->debuglevel(1);
- $imap->capability_checking(1);
- $imap->authenticate($user,$pass)
- or die "Unable to authenticate as $user ".$imap->error()."\n";
- $imap->select("INBOX");
- #my @all_uids = $imap->uidsearch('ALL'); #change here and to uidfetch from fetch
- my @all_uids = $imap->search('ALL'); #this is the sequence from newest to oldest
- foreach my $msg_id (@all_uids) {
- my %content = $imap->fetch($msg_id,{});
- print $content{$msg_id}->{BODY}->{BODY}, "\n";
- }
- $imap->disconnect();
Add Comment
Please, Sign In to add comment