sending mails with Home Assistant

Sending mails with Home Assistant is quite easy, but there is no integration, the configuration has to be done in the configuration.yaml itself.

Since the access to the mail provider is in plain text in configuration.yaml, I have outsourced the configuration to a separate yaml file. This does not increase security, but I can exclude the file from my github repository. I’ll make another post about Github.

To swap the config into your own yaml file, this entry must be added to configuration.yaml

notify: !include notify.yaml

Here is the code in notify.yaml

- name: "Mail_Guido"
  platform: smtp
  server: "smtp.meinProvider.de" ## enter your own SMTP server here
  port: 587
  timeout: 15
  sender: "user@domain.de" ## enter your own SMTP access data here
  encryption: starttls
  username: "user@domain.de" ## enter your own SMTP access data here
  password: "password" ## enter your own SMTP access data here
  recipient:
      - "RECIPIENT_N@domain.de"
  sender_name: "Home Assistant Aachen"

A mail can now be sent to the recipient in each automation with the following code.

service: notify.Mail_Guido
data:
  message: Please close the windows
  title: Please close the windows

Leave a Comment