in reply to Re: Getting started with Net::IMAP::Simple
in thread Getting started with Net::IMAP::Simple
Using the code right off the man page
# use strict; use warnings; use Net::IMAP::Simple; use Email::Simple; #use IO::Socket::SSL; $mailhost = "imap.gmail.com"; # Create the object my $imap = Net::IMAP::Simple->new( $mailhost, port => 993, use_ssl => 1, debug => 1, ) || die "Unable to connect to IMAP: $Net::IMAP::Simple::errstr\n"; # Log on if(!$imap->login('login','pass')){ print STDERR "Login failed: " . $imap->errstr . "\n"; exit(64); } # Print the subject's of all the messages in the INBOX my $nm = $imap->select('INBOX'); for(my $i = 1; $i <= $nm; $i++){ if($imap->seen($i)){ print "*"; } else { print " "; } my $es = Email::Simple->new(join '', @{ $imap->top($i) } ); printf("[%03d] %s\n", $i, $es->header('Subject')); } $imap->quit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Getting started with Net::IMAP::Simple
by mbethke (Hermit) on Feb 06, 2012 at 21:01 UTC |