SMTP auth: special characters in password field #2040

Open
opened 2026-02-28 01:01:50 -05:00 by deekerman · 6 comments
Owner

Originally created by @goooroooX on GitHub (Sep 25, 2021).

Problem

Email notification do not work when special characters are saved at password field (angle brackets in my case)

Expected behavior

Special characters are processing properly

Actual behavior

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/motioneye/handlers.py", line 837, in test
    subject=subject, message=message, files=[])
  File "/usr/lib/python2.7/site-packages/motioneye/sendmail.py", line 58, in send_mail
    conn.login(account, password)
  File "/usr/lib/python2.7/smtplib.py", line 608, in login
    (code, resp) = self.docmd(encode_cram_md5(resp, user, password))
  File "/usr/lib/python2.7/smtplib.py", line 572, in encode_cram_md5
    response = user + " " + hmac.HMAC(password, challenge).hexdigest()
  File "/usr/lib/python2.7/hmac.py", line 75, in __init__
    self.outer.update(key.translate(trans_5C))
TypeError: character mapping must return integer, None or unicode
   ERROR: notification email test failed: character mapping must return integer, None or unicode
Originally created by @goooroooX on GitHub (Sep 25, 2021). # Problem > Email notification do not work when special characters are saved at password field (angle brackets in my case) ## Expected behavior > Special characters are processing properly ## Actual behavior ``` Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/motioneye/handlers.py", line 837, in test subject=subject, message=message, files=[]) File "/usr/lib/python2.7/site-packages/motioneye/sendmail.py", line 58, in send_mail conn.login(account, password) File "/usr/lib/python2.7/smtplib.py", line 608, in login (code, resp) = self.docmd(encode_cram_md5(resp, user, password)) File "/usr/lib/python2.7/smtplib.py", line 572, in encode_cram_md5 response = user + " " + hmac.HMAC(password, challenge).hexdigest() File "/usr/lib/python2.7/hmac.py", line 75, in __init__ self.outer.update(key.translate(trans_5C)) TypeError: character mapping must return integer, None or unicode ERROR: notification email test failed: character mapping must return integer, None or unicode ```
Author
Owner

@starbasessd commented on GitHub (Sep 25, 2021):

Does your email server support hashed, tokenized, delimited or encrypted passwords?
"<" and ">" are disallowed characters in many systems and applications.

@starbasessd commented on GitHub (Sep 25, 2021): Does your email server support hashed, tokenized, delimited or encrypted passwords? "\<" and "\>" are disallowed characters in many systems and applications.
Author
Owner

@goooroooX commented on GitHub (Sep 25, 2021):

This is not my server, so I have no idea what kind of passwords it may support.
It is definitely support plain-text auth with special characters. And I cannot change the password.

@goooroooX commented on GitHub (Sep 25, 2021): This is not my server, so I have no idea what kind of passwords it may support. It is definitely support plain-text auth with special characters. And I cannot change the password.
Author
Owner

@starbasessd commented on GitHub (Sep 25, 2021):

You could try to edit the camera-X.conf file (X being the camera number)
sudo nano /etc/motioneye/camera-X.conf
Towards the end of the file should be a line beginning: on_event_start
Look for your password in that line (it is a VERY long line)
make sure your password shows as '<P@ssw0rd>'
(with the single quotes and your "<" & ">"as appropriate)
Save it, and trigger another email via motion.

@starbasessd commented on GitHub (Sep 25, 2021): You could try to edit the camera-X.conf file (X being the camera number) sudo nano /etc/motioneye/camera-X.conf Towards the end of the file should be a line beginning: on_event_start Look for your password in that line (it is a VERY long line) make sure your password shows as '\<P@ssw0rd\>' (with the single quotes and your "\<" & "\>"as appropriate) Save it, and trigger another email via motion.
Author
Owner

@goooroooX commented on GitHub (Sep 25, 2021):

root@a0d7b954-motioneye:/$ ls -al /etc/motioneye
total 20
drwxr-xr-x    2 root     root          4096 Aug 11 14:23 .
drwxr-xr-x    1 root     root          4096 Sep 26 02:00 ..
-rw-r--r--    1 root     root           249 Aug 11 14:23 motion.conf
-rw-r--r--    1 root     root          2858 Aug 11 14:23 motioneye.conf

Can't find password or camera settings in those files.
PS: running in HASS docker container.
PPS: found at /data/motioneye/

@goooroooX commented on GitHub (Sep 25, 2021): ``` root@a0d7b954-motioneye:/$ ls -al /etc/motioneye total 20 drwxr-xr-x 2 root root 4096 Aug 11 14:23 . drwxr-xr-x 1 root root 4096 Sep 26 02:00 .. -rw-r--r-- 1 root root 249 Aug 11 14:23 motion.conf -rw-r--r-- 1 root root 2858 Aug 11 14:23 motioneye.conf ``` Can't find password or camera settings in those files. PS: running in HASS docker container. PPS: found at `/data/motioneye/`
Author
Owner

@goooroooX commented on GitHub (Sep 25, 2021):

Removed all special characters from password and got the same error when trying to send Test Email.

on_event_start /usr/lib/python2.7/site-packages/motioneye/scripts/relayevent.sh 
"/data/motioneye/motioneye.conf" start %t; 
/usr/bin/python /usr/lib/python2.7/site-packages/motioneye/meyectl.pyc sendmail -c /data/motioneye/motioneye.conf 
'smtp.xxxx.xxx' '25' '***accountname_here***' '***password_here***' 'False' 'hass@from.mail.com' 
'personal@gmail.com' 'motion_start' '%t' '%Y-%m-%dT%H:%M:%S' '0'

Weird, but looks like this problem is not related to special characters.

@goooroooX commented on GitHub (Sep 25, 2021): Removed all special characters from password and got the same error when trying to send Test Email. ``` on_event_start /usr/lib/python2.7/site-packages/motioneye/scripts/relayevent.sh "/data/motioneye/motioneye.conf" start %t; /usr/bin/python /usr/lib/python2.7/site-packages/motioneye/meyectl.pyc sendmail -c /data/motioneye/motioneye.conf 'smtp.xxxx.xxx' '25' '***accountname_here***' '***password_here***' 'False' 'hass@from.mail.com' 'personal@gmail.com' 'motion_start' '%t' '%Y-%m-%dT%H:%M:%S' '0' ``` Weird, but looks like this problem is not related to special characters.
Author
Owner

@starbasessd commented on GitHub (Sep 26, 2021):

I thought you said "It is definitely support plain-text auth with special characters. And I cannot change the password."
It would have been helpful to mention how you were set up from the beginning.
Since it involves HA and their docker wrapper I must ask you to take that out of the equation.
Please install the motionEye version of docker:
https://github.com/ccrisan/motioneye/wiki/Install-In-Docker
and see if it occurs there.

@starbasessd commented on GitHub (Sep 26, 2021): I thought you said "It is definitely support plain-text auth with special characters. And I cannot change the password." It would have been helpful to mention how you were set up from the beginning. Since it involves HA and their docker wrapper I must ask you to take that out of the equation. Please install the motionEye version of docker: https://github.com/ccrisan/motioneye/wiki/Install-In-Docker and see if it occurs there.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/motioneye#2040
No description provided.