Skip to content

Unable to use certain charaters on imap outlook connection #99147

@danielecll

Description

@danielecll
  • Operating system and architecture: Windows 10 x86_64

I am having trouble logging in to the imap server "outlook.office365.com:993", basically sometimes the passwords i use contain special characters (-"_?$%& and such) that make the login fail with error: imaplib.IMAP4.error: b'LOGIN failed.' i know that this is a problem with the characters, because it appears only when the password contains some of them, while when the password is only numbers/letters it works fine. This is the code that is causing the issue:

def get_email(username, password):
    imap = imaplib.IMAP4_SSL(host="outlook.office365.com", port=993)
    imap.login(username, password)

i have tried many different things:
-Escaping the characters with \ and another time with ^
-Writing double quotes around the special characters
and more

online there is almost no documentation/examples on it. I also am not able to change the password to the account, as much as i would like to. And it also logins fine on the outlook site

For testing purposes here is a password similar to that one:

mozz@-rell@?9torey

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-emailtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions