Sure.
See the code below. Save it as .py file. It is crude but does the job.
Change here:
It will process 100 email in 8 seconds (your speed may vary), so leave it be.
It will put all email addresses in a text file with append option, so if it fails, delete the content of the txt file so far.
Emails will be extracted from the 'from' header so possibly very messy. You will need to process the list in excel (other) to get rid of duplication etc.
See the code below. Save it as .py file. It is crude but does the job.
Change here:
PHP Code:
pop_conn = poplib.POP3_SSL('mx.mail.com', '995')
pop_conn.user('youremail@someting.com')
pop_conn.pass_('password')
It will put all email addresses in a text file with append option, so if it fails, delete the content of the txt file so far.
Emails will be extracted from the 'from' header so possibly very messy. You will need to process the list in excel (other) to get rid of duplication etc.
PHP Code:
print >> open('emails-list.txt', 'a'), message['from']
Code:
import poplib,time
from email import parser
pop_conn = poplib.POP3_SSL('mx.mail.com', '995')
pop_conn.user('youremail@someting.com')
pop_conn.pass_('password')
#Get messages from server:
stt=time.ctime()
print 'getting messages started at %s\n' %(stt)
messages = [pop_conn.top(i,0) for i in range(1, len(pop_conn.list()[1]) + 1)]
endt=time.ctime()
print 'done getting messages at %s\n' %(endt)
# Concat message pieces:
messages = ["\n".join(mssg[1]) for mssg in messages]
#Parse message intom an email object:
messages = [parser.Parser().parsestr(mssg) for mssg in messages]
for message in messages:
print >> open('emails-list.txt', 'a'), message['from']
pop_conn.quit()

Comment