python / python/cpython

Unable to use certain charaters on imap outlook connection

Open
#99,147 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pending stdlib topic-email type-bug
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

  • 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the imaplib.IMAP4_SSL and login calls shown in the report, then reproduce the failure against outlook.office365.com:993 using passwords with and without special characters. Compare the observed LOGIN failed response and determine whether the issue is in imaplib or the server interaction; done means a reproducible diagnosis with a focused regression test or documented reason no library change is applicable.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.