Smtp image attachment broken after upgrade to 0.29.6

Hi,
I recently upgraded the HASS to 0.29.6, and I realized my email attachment script is not working anymore.
Basically i have a script that will save a foscam snapshot (foscam.jpg) to the file system, and then the script will email it to me as an attachment.

Here is the traceback
16-10-03 22:18:07 homeassistant.core: BusHandler:Exception doing job
Traceback (most recent call last):
File “/usr/local/lib/python3.4/dist-packages/homeassistant/core.py”, line 1162, in job_handler
func(args)
File “/usr/local/lib/python3.4/dist-packages/homeassistant/core.py”, line 1025, in _execute_service
service(call)
File “/usr/local/lib/python3.4/dist-packages/homeassistant/core.py”, line 825, in call
self.func(call)
File “/usr/local/lib/python3.4/dist-packages/homeassistant/components/notify/init.py”, line 111, in notify_message
notify_service.send_message(kwargs)
File “/usr/local/lib/python3.4/dist-packages/homeassistant/components/notify/smtp.py”, line 131, in send_message
msg = _build_multipart_msg(message, images=data.get(ATTR_IMAGES))
File “/usr/local/lib/python3.4/dist-packages/homeassistant/components/notify/smtp.py”, line 180, in _build_multipart_msg
** attachment = MIMEImage(attachment_file.read())

** File “/usr/lib/python3.4/email/mime/image.py”, line 43, in init
*
** raise TypeError(‘Could not guess image MIME subtype’)**
TypeError: Could not guess image MIME subtype

Hope this can help to debug the bug

Thank you

1 Like

Hi, I can’t help with the debug as I’m a newbie, but I did notice the same problem when the snapshot file is empty.
What I found was my old Foscam locked up for some reason and the “curl” statement was returning an empty file. Because the Mime type was unable to be read the automation just doesn’t send an email at all…
I resolved it by using a “wget” statement structured a little differently. If thats your issue I can post the wget tomorrow when I’m home.
I’d like the email to default to being sent if the MIME cant be determined…but I don’t know how to do that yet :slight_smile:

Thank you, Lets me try using wget as a work around

It will be nice if the real bug can be fixed

Hi,
Just following up for anyone looking for the wget for foscams…(this works for my circa 2008 cheapo foscam)

wget http://x.x.x.x/snapshot.cgi?user=admin&pwd=xxx -O /home/hass/.homeassistant/pics/snapshot.jpg

Replace the x with your relevant info. And of course modify the address where you are saving the picture.

@flatstrap Thank you