Question

I am using poplib to get email from the POP3 server.

But this error occurred:

*cmd* 'USER xxx@gmail.com'
*put* b'USER xxx@gmail.com'
*get* b'+OK send PASS\r\n'
*resp* b'+OK send PASS'
*cmd* 'PASS asdasd\n'
*put* b'PASS asdasd\n'
*get* b'-ERR bad command qj1pf12899100pbb.19\r\n'
*resp* b'-ERR bad command qj1pf12899100pbb.19'

here is the python code:

import getpass, poplib
def LoginGmail( email, pa ):
    M = poplib.POP3_SSL('pop.googlemail.com', '995') 
    M.set_debuglevel(2)
    user = email
    try:
        M.user(user)
        M.pass_(pa)
    except:
        print('Invalid credentials')
    else:
        print('Successful login')

...
in main():
loginGmail('test@gmail.com','asdasd')

However, in the function, when I try to type in the password (indicate as 'pa') and direct input, it works. It doesnt happen for user.

Please help, i've been trying for a day to figure it out but seem impossible for me :(

Thank you

Was it helpful?

Solution

Found the problem, when it read the password:

*cmd* 'PASS asdasd\n'
*put* b'PASS asdasd\n'

somehow it also read the \n that contains illegal character. Solve by removing the \n for each of the input value.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top