python分析邮件信息

python分析邮件信息

 

python提供了分析邮件原始信息MIME的工具

email.parser

 

下面举个例子,如何分析原始信息,然后打印出发件人,收件人和主题

from email.parser import Parser
parser = Parser()

rawMsg = """xxxxxxxxxxxxxxxxx"""  #这里的xxxxxxxx代表的邮件的原始信息
email = parser.parsestr(rawMsg)

print email.get('From')
print email.get('To')
print email.get('Subject')

 

版权所有,禁止转载. 如需转载,请先征得博主的同意,并且表明文章出处,否则按侵权处理.

    分享到:

Leave a Reply

Your email address will not be published. Required fields are marked *