Trying to connect to yandex mail with a script

import imaplib, email server = "imap.yandex.ru" port = "993" login = "login" password = "pass" box = imaplib.IMAP4_SSL(server, port) box.login(login, password) box.select() typ, data = M.search(None, 'ALL') for num in data[0].split() : typ, data = M.fetch(num, '(RFC822)') print 'Message %sn%sn' % (num, data[0][1]) box.close() box.logout() 

But an error occurs

maplib.error: [AUTHENTICATIONFAILED] LOGIN LOGIN Invalid credentials or IMAP is disabled

The situation is similar when using POP3.

Authentication data entered correctly.

What could be the reason?

  • one
    I have this code on Yandex quite well - andreymal

1 answer 1

The problem was that IMAP access was denied on the mail server.