The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.
I'm trying to mine the word count and some other random data on all the emails I've received through a particular email account. Do you guys know of an easy and fast automated way that one can download a bunch of emails from gmail and save them as text files?
All I'm really looking for is the subject and text body, but if it's in a format like extended headers and whatnot, then that's fine too! I can just parse it and stuff.
The code in the synopsis is almost exactly what you need, with the exception of writing the messages to a file handle instead of STDOUT and providing the application with some information it needs to work. In the (untested) example below, the first command line argument should be the address of the POP3 server, the second command line argument should be your username, and the third command line argument should be your password. The script will create a text file called messages.txt and all messages will be written (appended) to the file.
#perl get_messages.pl pop.mailserver.com batman s3cRe7l41RzFTW
get_messages.pl contains:
use Net::POP3;
$pop = Net::POP3->new($ARGV[0]);
open(MESSAGES, ">>messages.txt");
if ($pop->login($ARGV[1], $ARGV[2]) > 0) {
my $msgnums = $pop->list;
foreach my $msgnum (keys %$msgnums) {
my $msg = $pop->get($msgnum);
print MESSAGES @$msg;
$pop->delete($msgnum);
}
}
close(MESSAGES);
$pop->quit;
Hope this helps!
underdonk on
Back in the day, bucko, we just had an A and a B button... and we liked it.
Can't edit because I'm jailed, but I wanted to mention that this script will pull the messages directly from your mailbox on the server and delete them after they are downloaded (when the connection to the server is closed). If you don't want to delete them and leave them available for download later, comment out or delete the below line from the script.
$pop->delete($msgnum);
underdonk on
Back in the day, bucko, we just had an A and a B button... and we liked it.
Posts
The code in the synopsis is almost exactly what you need, with the exception of writing the messages to a file handle instead of STDOUT and providing the application with some information it needs to work. In the (untested) example below, the first command line argument should be the address of the POP3 server, the second command line argument should be your username, and the third command line argument should be your password. The script will create a text file called messages.txt and all messages will be written (appended) to the file.
get_messages.pl contains:
Hope this helps!