imaplib issue in GAE

162 views
Skip to first unread message

马不停蹄的猪

unread,
Jun 23, 2009, 11:19:17 AM6/23/09
to Google App Engine
In my project base on GAE, I uses imaplib to check email of Gmail.
Below is the code:

class Mailbox:
def __init__(self):
self.m = imaplib.IMAP4_SSL("imap.gmail.com")
.....

But below error occures when above instruction: imaplib.IMAP4_SSL
("imap.gmail.com") excuted.

Traceback (most recent call last):
File "/base/python_lib/versions/1/google/appengine/ext/webapp/
__init__.py", line 501, in __call__
handler.get(*groups)
File "/base/data/home/apps/srjsimblog/1.334408786956981127/
mailBlog.py", line 82, in get
gmailBox = Mailbox()
File "/base/data/home/apps/srjsimblog/1.334408786956981127/
mailBlog.py", line 31, in __init__
self.m = imaplib.IMAP4_SSL("imap.gmail.com")
File "/base/python_dist/lib/python2.5/imaplib.py", line 1128, in
__init__
IMAP4.__init__(self, host, port)
File "/base/python_dist/lib/python2.5/imaplib.py", line 163, in
__init__
self.open(host, port)
File "/base/python_dist/lib/python2.5/imaplib.py", line 1139, in
open
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
AttributeError: 'module' object has no attribute 'socket'

If I use imaplib in a standalone program with same instruction, it
works fine. Any body knows why? And how to resolve this issue?

Wooble

unread,
Jun 23, 2009, 1:20:58 PM6/23/09
to Google App Engine
You can't open socket connections in App Engine. There's no way at
present to connect to an email server; the workaround is to have
smtp2web post your email messages to your application instead of
having the application try to fetch them from somewhere.

You could also build an app running elsewhere that reads your email
and provides a REST interface to it.
Reply all
Reply to author
Forward
0 new messages