Shawk icon indicating copy to clipboard operation
Shawk copied to clipboard

Error with gmail account

Open AndrejHatzi opened this issue 7 years ago • 5 comments

raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials r22sm816511wmh.2 - gsmtp')

AndrejHatzi avatar Jan 30 '19 22:01 AndrejHatzi

It sounds like your username or password are incorrect. Can you tell me any more details about what you're seeing?

hawkins avatar Jan 31 '19 23:01 hawkins

My username and password are not incorrect, I'll provide you with more details!

Traceback (most recent call last):
  File "C:\Users\Kafka\Desktop\send.py", line 2, in <module>
    client = shawk.Client('[email protected]', 'genericemail')
  File "C:\Users\Kafka\AppData\Local\Programs\Python\Python36\lib\site-packages\shawk\Client.py", line 49, in __init__
    self.setup_inbox(pwd, auto=self.auto_refresh_enabled)
  File "C:\Users\Kafka\AppData\Local\Programs\Python\Python36\lib\site-packages\shawk\Client.py", line 171, in setup_inbox
    self.enable_auto_refresh()
  File "C:\Users\Kafka\AppData\Local\Programs\Python\Python36\lib\site-packages\shawk\Client.py", line 184, in enable_auto_refresh
    self.auto_refresh()
  File "C:\Users\Kafka\AppData\Local\Programs\Python\Python36\lib\site-packages\shawk\Client.py", line 196, in auto_refresh
    self.refresh()
  File "C:\Users\Kafka\AppData\Local\Programs\Python\Python36\lib\site-packages\shawk\Client.py", line 219, in refresh
    obj['BODY'] = value.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xea in position 725: invalid continuation byte
>>> 

Thank You, Andrej

AndrejHatzi avatar Feb 01 '19 01:02 AndrejHatzi

So full disclosure I haven't touched this code in about two years now, but this is what looks like is going on -

https://github.com/hawkins/Shawk/blob/master/shawk/Client.py#L275

# Convert messages to string format and simplify structure
        messages = []
        for uid in raw_msgs:
            obj = {}
            obj['UID'] = uid
            for key, value in raw_msgs[uid].items():
                try:
                    if key.decode('utf-8') == 'BODY[HEADER.FIELDS (FROM)]':
                        obj['FROM'] = email.utils.parseaddr(value.decode('utf-8'))[1]
                    else:
                        if key.decode('utf-8') == 'BODY[TEXT]':
                            obj['BODY'] = value.decode('utf-8') # <--- your error here
                        else:
                            obj[key.decode('utf-8')] = value.decode('utf-8')
                except AttributeError:
                    obj[key.decode('utf-8')] = value
            messages.append(obj)

It looks like we're trying to decode your email, but its body isn't UTF-8 encoded. I'm not familiar enough with typesets to know what values you might be sending to encounter this, though. Can you give me a sample text you tried to receive?

hawkins avatar Feb 02 '19 13:02 hawkins

Regardless, that's definitely a different error from the first one you shared in this issue 🤔 did you get further this time around?

hawkins avatar Feb 02 '19 13:02 hawkins

Thank you, I'll try this when I get home! Strange I did not change the code at all, I'll have a look into that! Thanks again, Andrej Hatzi

AndrejHatzi avatar Feb 04 '19 10:02 AndrejHatzi