Prev: Does a '_sre.SRE_Pattern' have state,or is it thread-safe?
Next: Pythonic Idiom For Searching An Include Path
From: Tim Chase on 24 Jun 2010 10:25 On 06/24/2010 04:47 AM, Xianwen Chen wrote: > Thanks a lot for your reply! I thought it would be simpler if the > problem was presented in a brief way. Unfortunately, not for this > case. > > Here is the detail. Free Yahoo! mail accounts can be accsessed via > IMAP protocal, however, a non-standard shake hand code is needed > before log in [1]: > > ID ("GUID" "1") > > . This is what I'm now working for. I tried: > > IMAP4.xatom('','ID ("GUID" "1")','',) > > and > > dest_srv.xatom('ID ("GUID" "1")') > > , but I got error messages. Any hint please? In general, it would be helpful to include the error-message(s) you get. However, I tried it with a junk Yahoo account I set up: from imaplib import IMAP4 i = IMAP4("imap.mail.yahoo.com") USER = 'yourusername(a)yahoo.com' PASS = 'your secret goes here' # per the Wikipedia page you gave # the ID has to happen before login i.xatom('ID ("GUID" "1")') i.login(USER, PASS) i.select() typ, data = i.search(None, 'ALL') for num in data[0].split(): typ, data = i.fetch(num, '(RFC822)') message = data[0][1].splitlines() subject = [line for line in message if line.lower().startswith('subject: ') ][0] print num, subject i.close() i.logout() and it worked. -tkc
From: Xianwen Chen on 25 Jun 2010 04:06 On Jun 24, 2:23 pm, Michael Torrie <torr...(a)gmail.com> wrote: > On 06/24/2010 03:47 AM, Xianwen Chen wrote: > > > , but I got error messages. Any hint please? > > Why not just use a proxy server: > > http://sourceforge.net/projects/imapidproxy/ Hi Michael Thanks a lot! Yes, it would be much more convenient. Actually, I have been using a modified version of Thunderbird [1] to access Yahoo! Mail IMAP server for months. The reason of using Python to access the mail server is to have less dependency on other software. Now I don't need Thunderbird anymore. Best regards, Xianwen [1] http://www.crasseux.com/linux/
From: Xianwen Chen on 25 Jun 2010 04:06 On Jun 24, 2:25 pm, Tim Chase <python.l...(a)tim.thechases.com> wrote: > On 06/24/2010 04:47 AM, Xianwen Chen wrote: > > > > > Thanks a lot for your reply! I thought it would be simpler if the > > problem was presented in a brief way. Unfortunately, not for this > > case. > > > Here is the detail. Free Yahoo! mail accounts can be accsessed via > > IMAP protocal, however, a non-standard shake hand code is needed > > before log in [1]: > > > ID ("GUID" "1") > > > . This is what I'm now working for. I tried: > > > IMAP4.xatom('','ID ("GUID" "1")','',) > > > and > > > dest_srv.xatom('ID ("GUID" "1")') > > > , but I got error messages. Any hint please? > > In general, it would be helpful to include the error-message(s) > you get. However, I tried it with a junk Yahoo account I set up: > > from imaplib import IMAP4 > i = IMAP4("imap.mail.yahoo.com") > USER = 'yourusern...(a)yahoo.com' > PASS = 'your secret goes here' > # per the Wikipedia page you gave > # the ID has to happen before login > i.xatom('ID ("GUID" "1")') > > i.login(USER, PASS) > i.select() > typ, data = i.search(None, 'ALL') > for num in data[0].split(): > typ, data = i.fetch(num, '(RFC822)') > message = data[0][1].splitlines() > subject = [line > for line in message > if line.lower().startswith('subject: ') > ][0] > print num, subject > i.close() > i.logout() > > and it worked. > > -tkc Hi Tim, The problem was the password. I was careless. Thanks for your advice. Next time I'll have error codes posted. And thanks a lot for your constructive example! I have a strange problem that "M = imaplib.IMAP4_SSL(M_addr) M.debug = 2" doesn't work. No verbose output at all. Any hint please? Best regards, Xianwen
First
|
Prev
|
Pages: 1 2 Prev: Does a '_sre.SRE_Pattern' have state,or is it thread-safe? Next: Pythonic Idiom For Searching An Include Path |