469,356 Members | 1,988 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

send email to string of emails

the code below outputs a string of emails (e.g. ['j**@jon.com',

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')
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
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
Mar 25 '06 #1
0 958

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Thom McGrath | last post: by
40 posts views Thread by ian | last post: by
2 posts views Thread by Leszek | last post: by
3 posts views Thread by chuckdfoster | last post: by
6 posts views Thread by Adam Honek | last post: by
3 posts views Thread by Frank | last post: by
4 posts views Thread by =?Utf-8?B?dHBhcmtzNjk=?= | last post: by
5 posts views Thread by Mike | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.