Eu sempre vi esse tipo de coisa com um pouco de código de cola. Um pequeno perl trabalharia para isso:
#!/usr/bin/perl -w
use strict;
use Net::POP3;
use DBI;
my $pop = Net::POP3->new('mail.server.com') or
die "shit, I can't connect\n";
my $dbh = DBI->connect('DBI:mysql:databasename', 'username', 'password'
) || die "Could not connect to database: $DBI::errstr";
if ($pop->login( 'username' , 'pass' ) > 0) {
my $msgnums = $pop->list;
MESSAGE: foreach my $msgnum (keys %$msgnums) {
my $msg = $pop->get($msgnum);
my ( $firstName, $lastName, $idNum );
if( $msg =~ /^Name:\s+([a-zA-Z]+)\s+([a-zA-Z]+)/){
$firstName = $1;
$lastName = $2;
}
if ( $msg =~ /^ID Number:\s+([0-9]+)/ ){
$idNum = $1;
}
$dbh->do('INSERT INTO exmpl_tbl VALUES( ? , ? , ?)', undef, ($firstName, $lastName, $idNum));
$pop->delete($msgnum);
next MESSAGE;
}
}
$pop->quit;
exit 0;