#!/usr/bin/env perl use strict; use warnings; use Mail::IMAPClient; use IO::Socket::SSL; # Connect to the IMAP server via SSL my $socket = IO::Socket::SSL->new( PeerAddr => 'imap.gmail.com', PeerPort => 993, ) or die "socket(): $@"; # Build up a client attached to the SSL socket. # Login is automatic as usual when we provide User and Password my $client = Mail::IMAPClient->new( Socket => $socket, User => 'youraccount', Password => 'yourpass', ) or die "new(): $@"; # Do something just to see that it's all ok print "I'm authenticated\n" if $client->IsAuthenticated(); my @folders = $client->folders(); print join("\n* ", 'Folders:', @folders), "\n"; # Say bye $client->logout();