motioneye-project / motioneye

A web frontend for the motion daemon.
GNU General Public License v3.0
3.92k stars 652 forks source link

Email notification - character mapping must return integer, None or unicode #1124

Open Artyum opened 5 years ago

Artyum commented 5 years ago

Hi and hello to everyone as this is my first post in this project.

I have a clean installation on Raspberry Pi 3+ with Raspbian Stretch. I follow Install-On-Raspbian guide with no problems. Camera, motion detection and most of things seems to work but email notification does not work at all. When I hit Test Email I got: Notification email failed: character mapping must return integer, None or unicode!

cat syslog:

Jan 20 14:17:45 raspberrypi meyectl[324]: Traceback (most recent call last): Jan 20 14:17:45 raspberrypi meyectl[324]: File "/usr/local/lib/python2.7/dist-packages/motioneye/handlers.py", line 885, in test Jan 20 14:17:45 raspberrypi meyectl[324]: subject=subject, message=message, files=[]) Jan 20 14:17:45 raspberrypi meyectl[324]: File "/usr/local/lib/python2.7/dist-packages/motioneye/sendmail.py", line 58, in send_mail Jan 20 14:17:45 raspberrypi meyectl[324]: conn.login(account, password) Jan 20 14:17:45 raspberrypi meyectl[324]: File "/usr/lib/python2.7/smtplib.py", line 607, in login Jan 20 14:17:45 raspberrypi meyectl[324]: (code, resp) = self.docmd(encode_cram_md5(resp, user, password)) Jan 20 14:17:45 raspberrypi meyectl[324]: File "/usr/lib/python2.7/smtplib.py", line 571, in encode_cram_md5 Jan 20 14:17:45 raspberrypi meyectl[324]: response = user + " " + hmac.HMAC(password, challenge).hexdigest() Jan 20 14:17:45 raspberrypi meyectl[324]: File "/usr/lib/python2.7/hmac.py", line 75, in init Jan 20 14:17:45 raspberrypi meyectl[324]: self.outer.update(key.translate(trans_5C)) Jan 20 14:17:45 raspberrypi meyectl[324]: TypeError: character mapping must return integer, None or unicode

I found some very old posts on this issue in the internet (like 5-10 years old) but I could not find a working solution. I would gladly help to test the fix for this.

Artyum commented 5 years ago

The solutions from https://github.com/ccrisan/motioneyeos/issues/595 don't work :(

Artyum commented 5 years ago

After some digging I've made a change:

vi /usr/lib/python2.7/smtplib.py
#response = user + " " + hmac.HMAC(password, challenge).hexdigest() 
response = user + " " + hmac.HMAC(str(password), str(challenge)).hexdigest()

Now I got a message: Notification email failed: authentication error! On a mailserver side I got:

warning: SASL authentication failure: incorrect digest response
warning: xxxx[xxx.xxx.xxx.xxx]: SASL CRAM-MD5 authentication failed: authentication failure

Is there a way to use AUTH_PLAIN instead of AUTH_CRAM_MD5 ?

Artyum commented 5 years ago

I got it working after change in /usr/lib/python2.7/smtplib.py at line 594:

#preferred_auths = [AUTH_CRAM_MD5, AUTH_PLAIN, AUTH_LOGIN]
preferred_auths = [AUTH_PLAIN, AUTH_CRAM_MD5, AUTH_LOGIN]

I hope it will help someone :D

hmouridsen commented 5 years ago

I got it working after change in /usr/lib/python2.7/smtplib.py at line 594:

#preferred_auths = [AUTH_CRAM_MD5, AUTH_PLAIN, AUTH_LOGIN]
preferred_auths = [AUTH_PLAIN, AUTH_CRAM_MD5, AUTH_LOGIN]

I hope it will help someone :D

Hi

I’m fighting with the same mail problem.

I have 3 cameras. All of them gives me the same error in email notification - however camera1 is sending the notification. Camera 2 and 3 is not sending notifications?

How can I edit this? I’m running the OS version

Thanks

Skyedra commented 5 years ago

Similar to Voodoofly's comment in issue 595, I get the "Notification email failed: character mapping must return integer, None or unicode" in Test E-mail mode, however, if I hit apply, I get real notification e-mails just fine.