1

这个脚本:

    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'

为什么?

4

2 回答 2

4

这会失败,因为 App-Engine 不允许在您的应用程序中打开套接字。请参阅http://code.google.com/appengine/docs/python/runtime.html中的“纯 Python”部分,以及http://groups.google.com/group/google-appengine/browse_thread/thread中的讨论/4a8764d266ec17af

于 2011-09-11T05:05:08.357 回答
0

请注意,虽然您无法从 App Engine 建立原始套接字连接,但您可以使用Mail API发送邮件,并且可以使用Gmail 收件箱供稿读取 Gmail 收件箱。

于 2011-09-12T18:29:41.510 回答