#!/usr/intel/bin/perl use strict; use warnings; # fill in your details here my $username = 'username@gmail.com'; my $password = 'password'; my $mailhost = 'imap.gmail.com'; my $mailport = 993; my $proxyhost = 'proxy-address'; my $proxyport = 1080; print "Proxy...\n"; use IO::Socket::Socks::Wrapper( { ProxyAddr => $proxyhost, ProxyPort => $proxyport, SocksDebug => 1, Timeout => 100 } ); # required modules use Net::IMAP::Simple; use Email::Simple; use IO::Socket::SSL; print "Proxy...\n"; use IO::Socket::Socks::Wrapper( { ProxyAddr => $proxyhost, ProxyPort => $proxyport, SocksDebug => 1, Timeout => 100 } ); # required modules use Net::IMAP::Simple; use Email::Simple; use IO::Socket::SSL; print "Connecting...\n"; # Connect my $imap = Net::IMAP::Simple->new( $mailhost, port => $mailport, use_ssl => 1 ) || die "Unable to connect to IMAP: $Net::IMAP::Simple::errstr\n"; print "Logging In...\n"; # Log in if ( !$imap->login( $username, $password ) ) { print STDERR "Login failed: " . $imap->errstr . "\n"; exit(64); } print "Selecting Folder...\n"; # Look in the the INBOX my $nm = $imap->select('Archive'); print "How Many Messages Are There...\n"; # How many messages are there? my ($unseen, $recent, $num_messages) = $imap->status(); print "unseen: $unseen, recent: $recent, total: $num_messages\n\n"; print "Quickly Look for unseen messages...\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') ); } } print "Disconnect...\n"; # Disconnect $imap->quit; print "Exit...\n"; exit;