send email to string of emails

K

Kun

the code below outputs a string of emails (e.g. ['(e-mail address removed)',
'(e-mail address removed)']

i would like to somehow send an email to everyone on the string of
emails telling them 'thanks for emailing me'

anyone know how to do this? much thanks ahead of time.


from imaplib import *
import getpass, re
m = IMAP4("xxxxxxxxxxxxxx")
m.login('xxxxx', 'xxxxxx')
m.select('Inbox')
status, data = m.search(None,'(SUBJECT "BIKES")')
assert status=='OK', "Error. Message: %s"%data
data = data[0]

#you get your results in a list and search returns only one result
assert data,"No results"

#cool, we have results, but IMAP's search command only returns IDs so we
have to fetch
#msgs now
status,senders = m.fetch(data.replace(' ',','),'(BODY.PEEK[HEADER.FIELDS
(FROM)])')
assert status=='OK', "Error. Message: %s"%data
''.join([''.join(t) for t in senders])
senderlist =''.join([''.join(t) for t in senders])
emails = re.findall('(\w+@\w+\.\w+)', senderlist)
print emails
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top