I
I
ivprokofyev2020-10-15 10:45:20
linux
ivprokofyev, 2020-10-15 10:45:20

Why doesn't INBOX reading via IMAP4_SSL work on the server?

I'm trying to read incoming messages in a box for my own domain on yandex via IMAP4_SSL. When run on a server under Linux, it returns an empty value - OK [], however, if run from a working laptop on Mac OS it works correctly - OK [b'521 522'].

The script itself:

from imaplib import IMAP4_SSL

def get_mail():
    connection = IMAP4_SSL(host=HOST, port=PORT)
    connection.login(user=LOGIN, password=PWD)
    status, msgs = connection.select()
    assert status == 'OK'
    typ, edata = connection.uid('SEARCH', None, '(FROM "{}")'.format(SENDER))
    print(edata)


Didn't find an answer on the internet. Help me to understand.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ivprokofyev, 2020-10-19
@ivprokofyev

Problem solved.
The SEARCH command does not always work correctly with (FROM "[email protected]"). Separating the query elements helped:

typ, edata = connection.uid('SEARCH', None, 'FROM',  'no_reply')

Moreover, the full address [email protected] also does not look for incoming letters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question