一个pop3邮箱类

一个pop3邮箱类

class Mbox:

    def __init__(self, ser, user, psw):
        import poplib
        self.post = poplib.POP3(ser)
        self.post.user(user)
        self.post.pass_(psw)
        self.n, size = self.post.stat()

    def __del__(self):
        self.post.quit()

    def __getitem__(self, index):
        rep, msg, size = self.post.retr(index+1)
        return msg

    def dele(self, index):
        self.post.dele(index+1)

if __name__ == '__main__':
    mbox = Mbox('pop3server', 'acc', 'password')
    for i in range(mbox.n):
        print '\n'.join(mbox[i])



象索引列表一样收取邮件
呵呵,有点意思。