Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; # required modules use Net::IMAP::Simple; use Email::Simple; use IO::Socket::SSL; # fill in your details here my $username = 'xxxxx'; my $password = 'yyyy'; my $mailhost = 'pop.gmail.com'; # Connect my $imap = Net::IMAP::Simple->new( $mailhost, port => 993, use_ssl => 1, ) || die "Unable to connect to IMAP: $Net::IMAP::Simple::errstr\n"; # Log in if ( !$imap->login( $username, $password ) ) { print STDERR "Login failed: " . $imap->errstr . "\n"; exit(64); } # Look in the the INBOX my $nm = $imap->select('INBOX'); # How many messages are there? my ($unseen, $recent, $num_messages) = $imap->status(); print "unseen: $unseen, recent: $recent, total: $num_messages\n\n"; ## Iterate through unseen messages for ( my $i = 1 ; $i <= $nm ; $i++ ) { if ( $imap->seen($i) ) { next; } else { my $es = Email::Simple->new( join '', @{ $imap->top($i) } ); printf( "[%03d] %s\n\t%s\n", $i, $es->header('From'), $es->header( +'Subject'), $es->body ('Body')); } } # Disconnect $imap->quit; exit;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: reading body of email not working -- get not top
by Discipulus (Canon) on Jun 01, 2017 at 08:05 UTC | |
by Anonymous Monk on Jun 01, 2017 at 08:41 UTC | |
Re: reading body of email not working
by hippo (Archbishop) on Jun 01, 2017 at 08:07 UTC | |
Re: reading body of email not working
by Eily (Monsignor) on Jun 01, 2017 at 07:44 UTC | |
by Anonymous Monk on Jun 01, 2017 at 08:01 UTC | |
by Eily (Monsignor) on Jun 01, 2017 at 08:12 UTC | |
by Anonymous Monk on Jun 01, 2017 at 08:02 UTC | |
Re: reading body of email not working
by Discipulus (Canon) on Jun 01, 2017 at 07:09 UTC | |
by Anonymous Monk on Jun 01, 2017 at 07:30 UTC |