当前位置:   article > 正文

python imap 接收邮件 --- imapclient 使用记录 一

imapclient

安装

pip install imapclient

使用案例

  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # Created by LiTianYao on 2018/3/6
  4. #
  5. from imapclient import IMAPClient
  6. class Imapmail(object):
  7. def __init__(self): # 初始化数据
  8. self.serveraddress = None
  9. self.user = None
  10. self.passwd = None
  11. self.prot = None
  12. self.ssl = None
  13. self.timeout = None
  14. self.savepath = None
  15. self.server = None
  16. def client(self): # 链接
  17. try:
  18. self.server = IMAPClient(self.serveraddress, self.prot, self.ssl, timeout=self.timeout)
  19. return self.server
  20. except BaseException as e:
  21. return "ERROR: >>> " + str(e)
  22. def login(self): # 认证
  23. try:
  24. self.server.login(self.user, self.passwd)
  25. except BaseException as e:
本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号