how to extract emails?

brownies

New member
Apr 28, 2010
60
1
0
Hey guys

i got tons of customer's emails in my gmail INBOX (not Address book) i wanna extract those emails and put them in an excel file. is there a quick way to do so?
 


There's another way. It involves exporting them to Facebook and then importing them to a Yahoo! mail or something. Google it.
 
Code:
#!/usr/bin/perl
use CGI qw/:cgi-lib/;
use CGI::Carp qw(fatalsToBrowser);
print "Content-type: text/html\n\n";
use GMail::Checker;
use Excel::Writer::XLSX;
my $gwrapper = new GMail::Checker();
my $gwrapper = new GMail::Checker(USERNAME => "username", PASSWORD => "password");
$gwrapper->login("username","password");
my ($nb, $size) = $gwrapper->get_msg_nb_size();
my @headers = $gwrapper->get_msg_headers(HEADERS => "FULL", MSG => 74);
@addys=();
foreach $head (@headers) {
    $foundit = $email =~ /^[-\w.]+@([a-z0-9][a-z-0-9]+\.)+[a-z]{2,4}$/i
    push(@addys,$foundit);
}
my $workbook = Excel::Writer::XLSX->new( 'customers.xls' );
$worksheet = $workbook->add_worksheet();
$format = $workbook->add_format();

foreach $line(@addys) {
    $count=1;
    $col = 0;
    $row = $count;
    $worksheet->write( $row, $col, '$line', $format );
    $count++;
    print "Writing to Excel: $line\n";
}
I didn't test it yet but it should work.

25 seconds of coding. Suck it phpers :)
 
We didnt just code all day did we? and now we're done you code random things for random people.

Go watch a movie, take a shower, unplug for an hour..

Your gonna start coding your dinner =)
 
set up a forward in gmail to a dummy email address (scripthunter@yourdomain.com).

On your vps set up an alias like "scripthunter@yourdomain.com emailscraper" in your virtualusers file and run "make map hash virtuserstable < virtuserstable" to rebuild your hash table. (sendmail can't forward from virtusertable to a script).

In aliases add something like "emailscraper: |"/some/path/to/some/script" and run newaliases to rebuild the new aliases.

in your script, read stdin and save to a variable. then do a preg_match for email addresses and append them to a file.