2011-12-09 2 views

답변

1

이 명령은 imaplib에 의해 구현되지 않습니다.

나는 이것이 약간의 해킹이라는 것을 알고 있지만 정확히 같은 이유로 XLIST를 실행해야했습니다.

list()가 imaplib 소스에 어떻게 구현되었는지 살펴보면 imaplib의 IMAP4_SSL 클래스를 상속하고 xlist() 명령을 추가했습니다. 그래서, adv_imaplib.py 추가로 :

import imaplib 

imaplib.Commands['XLIST'] = ('AUTH', 'SELECTED') 

class ADV_IMAP4_SSL(imaplib.IMAP4_SSL): 

    def xlist(self, directory='""', pattern='*'): 
    """(X)List mailbox names in directory matching pattern. Using Google's XLIST extension 

    (typ, [data]) = <instance>.xlist(directory='""', pattern='*') 

    'data' is list of XLIST responses. 
    """ 
    name = 'XLIST' 
    typ, dat = self._simple_command(name, directory, pattern) 
    return self._untagged_response(typ, dat, name) 

지금 바로 ADV_IMAP4_SSL 대신 IMAP4_SSL을 만들고, 나를 위해 작동) (xlist 호출합니다.

1

다른 접근 방법은 타사 IMAPClient 라이브러리를 사용하는 것입니다.

XLIST out of the box을 지원합니다.