def GetEmil_id(self, n): '''获取第n封邮件''' server = zmail.server(self.user, self.password, self.host) #获取邮箱信息 mailbox_info = server.stat() print('邮件的数量:%s,邮箱的大小:%s' % mailbox_info) #获取邮件 mail = server.get_mail(n) zmail.show(mail) return mail
################查收邮件########################### ################################################### import zmail server = zmail.server('*****@*****.**', 'family404smtp') mail = server.get_latest() mail['subject'] #邮件标题 mail = server.get_mail(3) #第二封邮件 mail = server.get_mails(subject='GitHub', after='2018-1-1', sender='github') # 条件搜索邮件 # 解析邮件信息 mail_info = server.get_info() mailbox_info = server.stat() # 展示邮件 import zmail server = zmail.server('*****@*****.**', 'family404smtp') mail = server.get_latest() zmail.show(mail) # 获得附件 zmail.get_attachment(mail) # 保存邮件 import zmail server = zmail.server('*****@*****.**', 'family404smtp') mail = server.get_latest() zmail.save_eml(mail) zmail.save_eml(mail, name='hello.eml', path='/usr/home') # 读取磁盘上的邮件 import zmail mail_as_raw = zmail.read_eml('/usr/home/hello.eml') # Abspath will be better # 解析成zmail格式邮件 mail = zmail.decode(mail_as_raw)
def getLatestMailInfo(self): latest_mail = self.server.get_latest() zmail.show(latest_mail)
# fr_server=zmail.server(config['fr_mail'],config['fr_passwd'],smtp_host='192.168.102.207',smtp_port='25',smtp_ssl=False) fr_server = zmail.server("*****@*****.**", "AB12345678c", smtp_host='192.168.102.207', smtp_port='25', pop_host="192.168.102.207", pop_port="110", pop_ssl=False, smtp_ssl=False) # server = zmail.server('username','password',smtp_host='smtp.163.com',smtp_port=994,smtp_ssl=True,pop_host='pop.163.com',pop_port=995,pop_tls=True) mailbox_info = fr_server.stat() print(mailbox_info) latest_mail = fr_server.get_latest() zmail.show(latest_mail) ret = fr_server.send_mail("*****@*****.**", { 'subject': "aaa", 'content_text': "bbb" }) print(ret) # server = EmailEngine("*****@*****.**","opcu@163") # server.getLatestMailInfo() """ print("--------------------") #server.sendMail("*****@*****.**", '功能验证 function', '我需要验收,逗吧') server.forwardMail("*****@*****.**", 1200) headers = server.getMailHeader(1100,1110) print("-------!!!---------")
def show_mail(mail): zmail.show(mail)
def read_mail(self): mails = self.server.get_mails() for item in mails: print(zmail.show(item))