这个脚本:
import imaplib
user = "dave.trindall@gmail.com"
pwd = "***"
m = imaplib.IMAP4_SSL("imap.gmail.com")
m.login(user,pwd)
m.select("Inbox") # here you a can choose a mail box like INBOX instead
m.search("NEW")
为我犯了这个错误:
Traceback (most recent call last):
File "c:\Program Files\Google\google_appengine\google\appengine\ext\webapp\_webapp25.py", line 701, in __call__
handler.get(*groups)
File "c:\Users\Dave\git_stuff\Touch Base\Touch Base\main.py", line 30, in get
m = imaplib.IMAP4_SSL("imap.gmail.com")
File "c:\Python26\lib\imaplib.py", line 1138, in __init__
IMAP4.__init__(self, host, port)
File "c:\Python26\lib\imaplib.py", line 163, in __init__
self.open(host, port)
File "c:\Python26\lib\imaplib.py", line 1149, in open
self.sock = socket.create_connection((host, port))
AttributeError: 'module' object has no attribute 'create_connection'
为什么?
答案 0 :(得分:4)
此操作失败,因为App-Engine不允许在您的应用程序中打开套接字。请参阅http://code.google.com/appengine/docs/python/runtime.html中的“纯Python”部分,以及http://groups.google.com/group/google-appengine/browse_thread/thread/4a8764d266ec17af
上的讨论答案 1 :(得分:0)
请注意,虽然您无法从App Engine进行原始套接字连接,但您可以使用Mail API发送邮件,并且可以使用Gmail Inbox Feed阅读Gmail收件箱。