Sample code for 30+ languages & platforms
Perl

Read Gmail POP3 Mailbox

Reads the header for each email in a GMail POP3 mailbox and displays the FROM and SUBJECT header fields. In your GMail "Forwarding and POP" settings, be sure to select "When messages are accessed with POP keep Gmail's copy in the Inbox".

Chilkat Perl Downloads

Perl
use chilkat();

$success = 0;

# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

# The mailman object is used for receiving (POP3) 
# and sending (SMTP) email.
$mailman = chilkat::CkMailMan->new();

# Set the GMail account POP3 properties.
$mailman->put_MailHost("pop.gmail.com");
$mailman->put_PopUsername("myLogin");
$mailman->put_PopPassword("myPassword");
$mailman->put_PopSsl(1);
$mailman->put_MailPort(995);

# Read mail headers and one line of the body.
# To get the full emails, set headersOnly = 0
$bundle = chilkat::CkEmailBundle->new();
$keepOnServer = 1;
$headersOnly = 1;
$numBodyLines = 1;
$success = $mailman->FetchAll($keepOnServer,$headersOnly,$numBodyLines,$bundle);
if ($success == 0) {
    print $mailman->lastErrorText() . "\r\n";
    exit;
}

$i = 0;
$email = chilkat::CkEmail->new();
while ($i < $bundle->get_MessageCount()) {
    $bundle->EmailAt($i,$email);

    # Display the From email address and the subject.
    print "From: " . $email->ck_from() . "\r\n";
    print "Subject: " . $email->subject() . "\r\n";

    $i = $i + 1;
}