Appdaemon smtp app?

Anyone got a simple appdaemon smtp app to send out emails?

I use the SMTP notification service - that way its just a service call to notify

Yea, I was just hoping for something where the recipient isn’t hard coded.

i think you want to use the python smtplib

https://docs.python.org/2/library/smtplib.html

1 Like

try this one…python smtp library

I am looking for this too, using the Home Assistant services.

This works

self.call_service('notify/email_info', title = notification_title, message = notification_body)

This also works

self.notify(notification_body, title = notification_title, name = 'email_info')

but sends out a plain text email message. is there any way to get to the built in html message body format

This does not work

self.call_service('notify/email_info', title = notification_title, html = notification_body)

Thanks

you need to check out the HA services.
i dont think HA excepts notifications without a message argument, so that why the last one doesnt work.

Here are the docs
https://www.home-assistant.io/integrations/smtp/

yaml to send html email

burglar:
  alias: Burglar Alarm
  sequence:
    - service: shell_command.snapshot
    - delay:
          seconds: 1
    - service: notify.NOTIFIER_NAME
      data:
          message: 'Intruder alert at apartment!!'
          data:
            images:
              - /home/pi/snapshot1.jpg
              - /home/pi/snapshot2.jpg
            html: >
              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transit...

This all works fine, I just cannot send an HTML email from an AppDaemon python script

so you need this:

self.call_service('notify/email_info', message = "Intruder alert at apartment!!", data = {"images":["/home/pi/snapshot1.jpg","/home/pi/snapshot2.jpg"], "html": "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transit..."})

you just need to translate everything from yaml to dicts.

1 Like

Wow, brilliant thanks

Is this documented anywhere?
Am i missing some docs or looking in the wrong place?

self.notify('aaa', title = notification_title, name = 'email_info', data = {"html": notification_body})
self.call_service('notify/email_info', message = 'aaa', data = {'html': notification_body})

Both of the above work for HTML emails

from what I see in the email and internet headers of the received email, is that HA requires the ‘message’ field but it is not actually used for a HTML message.

Thanks again

no there is nowhere documented how exactly translate HA services to call_service.
it is in principle the knowledge how to translate yaml to python dicts.