Problems with sending images using SMTP integration

I’ve read just about every Google search result on HA’s SMTP integration and sending images and I still am failing.

I have the following in my configuration.yaml file:

homeassistant:
  allowlist_external_dirs:
    - "/config/media"


notify:
  - platform: smtp
    name: "family_sms"
    server: "░░░░░░.░░░░░░░░░.com"
    port: 465
    encryption: tls
    username: !secret smtp_user
    password: !secret smtp_pass
    sender: "░░░░░░░░░░░@░░░░░░░░.net"
    sender_name: Home Assistant
    recipient:
      - "░░░░░░░░░@░░░░░░░░░.com"
      - "░░░░░░░@░░░░░░.net"

My STMP recipients are an email address and a MMS recipient via email forwarder.

And this in my test automation:

alias: Camera Detection Test
description: ""
triggers: []
conditions: []
actions:
  - action: camera.snapshot
    metadata: {}
    data:
      filename: /config/media/temp4.jpg
    target:
      entity_id: camera.ai_pro_driveway_high_resolution_channel
  - action: notify.family_sms
    metadata: {}
    data:
      message: test
      title: sms test
      data:
        image:
          - /config/media/temp4.jpg
        html: |
          <img src="cid:temp4.jpg">
mode: single

By selecting “run actions” on my test automation, I’ve verified that the snapshot is actually being created:
image

and I can view it locally:

I am receiving both the email and MMS message but without the image! The email just show a broken image icon, and the MMS message just has the subject/title and the message text.

Above is the in-line image test, but I have tried sending it as an attachment by removing the two lines

        html: |
          <img src="cid:temp4.jpg">

from the automation. Results were the same. I guess it needs to be said that I also verified that I can send an email to the SMS/MMS forwarder with a picture as an attachment, or as an in-line image and successfully by using my email program. HA Core logs do not show any errors from executing the automation.

Can anyone give me an idea where to look for additional clues as to why this is not working? Thanks.

SMTP documentation says it’s images: not image:, even if there’s only one.

@TROON - OMG! thank you so much. What a stupid mistake. I’ve been beating my head against this for the whole weekend. It’s surprising that the incorrect spelling did not generate any errors.

So, attaching works for the SMS. The simple HTML embed that I had does not. I’ll have to play some more with that and see if a full HTML document will work with SMS/MMS.

It also works both ways (embed, attach) with the email address.

Again - many thanks.

1 Like

FYI to others - the Unifi Protect Integration page UniFi Protect - Home Assistant has an example where the notify portion uses image: and not images:

actions:
  - data:
      message: "Motion detected at Camera XXX"
      data:
        image: >-
          /api/unifiprotect/thumbnail/{{ config_entry_id(trigger.entity_id) }}/{{ trigger.from_state.attributes.event_id }}
        video: >-
          /api/unifiprotect/video/{{ config_entry_id(trigger.entity_id) }}/{{ trigger.from_state.attributes.event_id }}
    action: notify.mobile_app_your_device # Replace with your notification target

Be sure to check integration page for YOUR notify integration to see the correct fields for your implementation.

A bit of an old thread, but thought I should mention something. I used to use the smtp integration, but then went over to the gmail integration as it seemed simpler. I was however banging my head up against the wall working out why I couldn’t send images from my security cameras - at least until I discovered that it wasn’t supported.

So went back to smtp, but remembered why I changed as it always seemed a bit flakey. I also used to have the twitter integration but since it moved to X things had also broken. I started to try to fix that, but found that there was now a limitation of 100 messages per month - which is probably enough for me, but well… that was just one of the reasons why I really didn’t want to use X.

Then it clicked - I could use the signal integration. Required a mobile number that was not registered to signal (I had one that I use for internet backup), and something running the api. Easy enough to spin the api system in a container for me, then link it to the number. Tested - all good.

I now have the ability to send the images to a private group, add members of the family to the group if they are interested etc etc. Not saying to give up on the smtp, gmail or even twitter integrations, just noting that there are alternatives. :wink:

Did you get HTML image embedding in an email working?