- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
wxpython 相关
1. 主要使用了 poplib 组件
?
# -*- coding: utf-8 -*-
import poplib
from email import parser
host =
username = mine@
password = *******
pop_conn = poplib.POP3_SSL(host)
pop_conn.user(username)
pop_conn.pass_(password)
#Get messages from server:
messages = [pop_conn.retr(i) for i in range(1, len(pop_conn.list()[1]) + 1)]
# Concat message pieces:
messages = [\n.join(mssg[1]) for mssg in messages]
#Parse message intom an email object:
messages = [parser.Parser().parsestr(mssg) for mssg in messages]
for message in messages:
print message[Subject]
pop_conn.quit()
?
优点: 可以输出内容
缺点: 只检测一次
?
?
2. 使用第三方插件 chilkat
?
# -*- coding: utf-8 -*-
import sys
import chilkat
host =
username = mine@
password = ******
# The mailman object is used for receiving (POP3)
# and sending (SMTP) email.
mailman = chilkat.CkMailMan()
# Any string argument automatically begins the 30-day trial.
success = mailman.UnlockComponent(30-day trial)
if (success != True):
print Component unlock failed
sys.exit()
# Set the GMail account POP3 properties.
mailman.put_MailHost(host)
mailman.put_PopUsername(username)
mailman.put_PopPassword(password)
mailman.put_PopSsl(True)
mailman.put_MailPort(995)
# Read mail headers and one line of the body.
# To get the full emails, call CopyMail instead (no arguments)
bundle = mailman.GetAllHeaders(1)
if (bundle == None ):
print mailman.lastErrorText()
sys.exit()
for i in range(0,bundle.get_MessageCount()):
email = bundle.GetEmail(i)
# Display the From email address and the subject.
print email.ck_from()
print email.subject() + \n
?
安装见附件
主页:/products.asp
安装:/installPython27.asp
?
安装很简单,点击 showPythonPath.bat 测试一下环境,然后复制 _chilkat.pyd 和 chilkat.py 到 Python27\Lib\site-packages\ 下就可以
?
?
优点: 可以多次检测
缺点: 只可以看到来源和主题,无法看到内容
?
?
?
3. 检测邮件,返回未读数值
?
def gmail_checker(username,password):
import imaplib,re
i=imaplib.IMAP4_SSL()
try:
i.login(username,password)
x,y=i.sta
文档评论(0)