import imaplib, re
import os
import time
import socket
imap_host = 'imap.gmail.com'
mail = imaplib.IMAP4_SSL(imap_host)
mail.login("[email protected]", "sddd")
while True:
try:
print 'Connecting to Inbox..'
mail.select("inbox") # connect to inbox.
result, data = mail.uid('search', None, 'UNSEEN')
uid_list = data[0].split()
print len(uid_list), 'Unseen emails.'
if len(uid_list) > 20:
os.system('heroku restart --app xx-xx-203')
time.sleep(30)
except:
print 'Error'
imap_host = 'imap.gmail.com'
mail = imaplib.IMAP4_SSL(imap_host)
mail.login("[email protected]", "xxx")
pass
完美的作品,但有時它與崩潰:的Python:Gmail的封未讀郵件崩潰
Restarting processes... done
Connecting to Inbox..
Error
Traceback (most recent call last):
File "gmail_new9.py", line 24, in <module>
mail.login("[email protected]", "ddddd")
File "/usr/lib/python2.6/imaplib.py", line 498, in login
typ, dat = self._simple_command('LOGIN', user, self._quote(password))
File "/usr/lib/python2.6/imaplib.py", line 1060, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "/usr/lib/python2.6/imaplib.py", line 893, in _command_complete
self._check_bye()
File "/usr/lib/python2.6/imaplib.py", line 808, in _check_bye
raise self.abort(bye[-1])
imaplib.abort: [UNAVAILABLE] Temporary System Error
我怎樣才能解決這個問題?