Python Forum
imaplib problem - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: imaplib problem (/thread-19738.html)



imaplib problem - levann - Jul-12-2019

Hi there

I am trying to remake python email bot, which will satisfy my needs.
I have used code from this source

I had some errors, and I was able to resolve them, but now I am stacked.

I am getting this error

Error:
Traceback (most recent call last): File "/usr/lib64/python3.6/imaplib.py", line 1019, in _command_complete typ, data = self._get_tagged_response(tag) File "/usr/lib64/python3.6/imaplib.py", line 1131, in _get_tagged_response self._check_bye() File "/usr/lib64/python3.6/imaplib.py", line 934, in _check_bye raise self.abort(bye[-1].decode(self._encoding, 'replace')) imaplib.abort: mail.nls.ge Zimbra IMAP4rev1 server closing connection During handling of the above exception, another exception occurred: Traceback (most recent call last): File "main.py", line 114, in <module> msgs = get_unread() File "main.py", line 51, in get_unread uids = i.search(['UNSEEN']) File "/usr/lib64/python3.6/site-packages/imapclient/imapclient.py", line 956, in search return self._search(criteria, charset) File "/usr/lib64/python3.6/site-packages/imapclient/imapclient.py", line 982, in _search data = self._raw_command_untagged(b'SEARCH', args) File "/usr/lib64/python3.6/site-packages/imapclient/imapclient.py", line 1445, in _raw_command_untagged typ, data = self._raw_command(command, args, uid=uid) File "/usr/lib64/python3.6/site-packages/imapclient/imapclient.py", line 1507, in _raw_command return self._imap._command_complete(to_unicode(command), tag) File "/usr/lib64/python3.6/imaplib.py", line 1021, in _command_complete raise self.abort('command: %s => %s' % (name, val)) imaplib.abort: command: SEARCH => mail.nls.ge Zimbra IMAP4rev1 server closing connection
Any ideas? :)


RE: imaplib problem - levann - Jul-12-2019

Forgot to write info
I'm using Zimbra mail server. Initialization of SMTP and IMAP is going without errors.
I'm getting this error after receiving new email


RE: imaplib problem - micseydel - Jul-13-2019

Can you re-frame your question with 5-10 lines of code (in code tags) along with any instructions for how to get the code to reproduce the problem?


RE: imaplib problem - levann - Jul-15-2019

(Jul-13-2019, 05:29 PM)micseydel Wrote: Can you re-frame your question with 5-10 lines of code (in code tags) along with any instructions for how to get the code to reproduce the problem?

Sure

For imap initialization
def imap_init():
    """
    Initialize IMAP connection
    """
    print("Initializing IMAP... ")
    global i
    i = imapclient.IMAPClient(imapserver, ssl_context=ssl_context)
    c = i.login(radr, pwd)
    i.select_folder("INBOX", readonly=True)
    print("Done. ")
for fetch unread emails

def get_unread():
    global i
    uids = i.search(['UNSEEN'])
    if not uids:
        return None
    else:
        print("Found %s unreads" % len(uids))
        return i.fetch(uids, ['BODY[]', 'FLAGS'])