An open API service indexing awesome lists of open source software.

https://github.com/microteq/email_notifier

Send email notifications from Home Assistant
https://github.com/microteq/email_notifier

email email-notification email-sender home-assistant home-automation integration notifications

Last synced: 2 months ago
JSON representation

Send email notifications from Home Assistant

Awesome Lists containing this project

README

          

[![License](https://img.shields.io/github/license/microteq/email_notifier.svg)](LICENSE)
[![HACS Supported](https://img.shields.io/badge/HACS-Supported-green.svg)](https://github.com/custom-components/hacs)
![GitHub Activity](https://img.shields.io/github/commit-activity/y/microteq/email_notifier.svg?label=commits)
[![Stable](https://img.shields.io/github/release/microteq/email_notifier.svg)](https://github.com/microteq/email_notifier/releases/latest)

# Home Assistant Email Notifier
**Sending email notifications from Home Assistant.**

The Email Notifier is an integration for Home Assistant allowing you to send email messages, notifications or alerts to any email recipient. The Email Notifier is based on the Home Assistant SMTP integration, but has a user interface for the email server configuration.



## Features
- Send Home Assistant alerts, notifications and messages to email recipient(s).
- UI-based configuration for easy setup.
- Backward compatibility with YAML configuration.
- Supports sending messages to multiple recipients.
- Send images and attachments.
- Send plain text or html messages.
- Options flow to update configurations without reinstallation.
- Detailed error handling and logging for troubleshooting.

## Installation

### HACS (recommended)
[![Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=microteq&repository=email_notifier)

This is the recommended installation method.

- Search for and install the Email Notifier integration from HACS
- Restart Home Assistant

### Manual
- Download the latest release.
- Copy the contents of custom_components into the /config/custom_components directory of your Home Assistant installation.
- Restart Home Assistant.

## Configuration

In your Home Assistant go to _Settings_ > _Devices & services_ and click on _Add integration_. In the search field, search for _email_ and select the integration. This will add an email account entity, you can use to send email notifications from. Fill in the needed information of your mail server.

### Configuration fields

#### SMTP Server
SMTP server which is used to send the notifications.

#### Port (default: 587)
The port that the SMTP server is using.

#### Username
Username for the SMTP account.

#### Password
Password for the SMTP server that belongs to the given username.

#### Sender Email
Email address of the sender.

#### Recipient Email(s)
Default email address of the recipient of the notification. This can be a recipient address or a comma delimited list of addresses for multiple recipients.
This is where you want to send your email notifications by default (when not specifying recipients in the action). Any email address(es) specified in the action’s recipient field will override this recipient content.

#### Sender name
Sets a custom ‘sender name’ in the emails headers.

#### Encryption (default: starttls)
Set mode for encryption, starttls, tls or none.

#### Timeout (default: 15)
The timeout in seconds that the SMTP server is using.



### Google Mail
Google has some extra layers of protection that need special attention. You must use an **application-specific** password in your notification configuration.

If any of the following conditions are met you will not be able to create an app password:

- You do not have 2-step verification enabled on your account.
- You have 2-step verification enabled but have only added a security key as an authentication mechanism.
- Your Google account is enrolled in Google’s Advanced Protection Program.
- Your Google account belongs to a Google Workspace that has disabled this feature. Accounts owned by a school, business, or other organization are examples of Google Workspace accounts.

## Usage

The Email Notifier creates email accounts from which notifications can be sent. Each account also has a default recipient. In Home Assistant, sending a message is typically used as an action in an automation.

### Using the user interface

#### Method A
In your automation, click on _Add action_, then on _Notifications,_ and select the action _Send a notification message_. In the _Message_ field, enter your message, and as _Target_, click on _Choose entity_ and select one (or more) sender email account(s). The recipients(s) will be the default recipients(s) defined in the mail account configuration. Then save your action.

#### Method B
In your automation, click on _Add action_, then search for _email_ and select the _Email Notifier: Send Email_ action. Select your sender account and fill out the custom fields you need to send your email, such as recipient(s), subject, plain message, html message, attachments or images.

### Writing YAML

#### Method A

```
alias: Send Test Message
description: ""
triggers: []
conditions: []
actions:
- action: notify.send_message
data:
message: "This is a test message from Home Assistant"
target:
entity_id: notify.email_notification_sender_1
mode: single
```

#### Medod B

```
alias: Send Test Message
description: ""
triggers: []
conditions: []
actions:
- action: email_notifier.send
metadata: {}
data:
account: notify.email_notification_sender_0
recipients: "user@example.com"
title: "Complete Feature Demo"
message: "Plain text version of this email"
html: |


Feature Demonstration


This email showcases all features:




  • HTML formatting

  • Inline images

  • File attachments

  • Custom sender info




images: |
https://example.com/logo.png
attachments: |
/config/www/report.pdf
https://example.com/document.pdf
from_address: "noreply@mydomain.com"
sender_name: "Home Assistant Demo"
reply_to: "support@mydomain.com"
```

### HTML Email Support
**Description:** Send rich HTML emails with full styling, images, and formatting.

**Usage Example:**
```yaml
service: email_notifier.send
data:
account: notify.email_notification_sender_0
title: "Alert Notification"
message: "Plain text fallback"
html: |


Alert


This is a rich HTML email with formatting.



  • Feature 1

  • Feature 2




recipients: "user@example.com"
```
**Features:**
- Sends as multipart MIME with both plain text and HTML versions
- Email clients will display HTML version if supported, fall back to plain text otherwise
- Supports inline images (see Images section below)

### File Attachments (Local & Remote)
**Description:** Attach any file type to emails, supporting both local files and remote URLs.

**Supported Sources:**
- Local files: `/config/www/report.pdf`
- Remote URLs: `https://example.com/document.pdf`

**Supported File Types:**
- Documents: PDF, DOCX, TXT, CSV, XLSX
- Images: JPG, PNG, GIF, BMP
- Archives: ZIP, RAR, TAR
- Any other file type

**Usage Example:**
```yaml
service: email_notifier.send
data:
account: notify.email_notification_sender_0
title: "Monthly Report Package"
message: "Please find attached the monthly reports."
attachments: |
/config/www/report.pdf
https://www.bhphotovideo.com/lit_files/1220335.pdf
/config/www/data.csv
https://example.com/remote_document.pdf
recipients: "user@example.com"
```

**Input Format:**
- Enter one file path or URL per line in the multiline text box
- Empty lines are automatically filtered out
- Whitespace is trimmed from each line
- Supports http:// and https:// protocols

### Inline Images (Local & Remote)
**Description:** Embed images directly in HTML emails using Content-ID references.

**Usage Example:**
```yaml
service: email_notifier.send
data:
account: notify.email_notification_sender_0
title: "Camera Alert"
html: |


Motion Detected


Camera snapshot:



Logo:





images: |
/config/www/camera.jpg
https://example.com/logo.png
recipients: "user@example.com"
```

**How It Works:**
- Images are embedded using Content-ID (cid:filename)
- Reference images in HTML with ``
- Supports both local files and remote URLs

### Custom "From" Address
**Description:** Override the sender's email address for individual messages.

**Usage Example:**
```yaml
service: email_notifier.send
data:
account: notify.email_notification_sender_0
title: "Security Alert"
message: "Motion detected at front door"
from_address: "security@mydomain.com"
recipients: "user@example.com"
```

**Notes:**
- Overrides the configured sender address for this message only
- The SMTP envelope sender remains the configured account (required for authentication)
- The displayed "From" address in the email will be the custom address

### Custom Display Name (Sender Name)
**Description:** Set a custom display name for the sender.

**Usage Example:**
```yaml
service: email_notifier.send
data:
account: notify.email_notification_sender_0
title: "Alert"
message: "System notification"
sender_name: "Home Security System"
recipients: "user@example.com"
```

**Combined with Custom From Address:**
```yaml
service: email_notifier.send
data:
account: notify.email_notification_sender_0
title: "Alert"
message: "Notification"
from_address: "alerts@mydomain.com"
sender_name: "Home Assistant Alerts"
recipients: "user@example.com"
```

This will display as: **"Home Assistant Alerts "**


### Custom Reply-To Address
**Description:** Specify where recipient replies should be directed.

**Usage Example:**
```yaml
service: email_notifier.send
data:
account: notify.email_notification_sender_0
title: "Survey"
message: "Please reply with your feedback"
reply_to: "feedback@mydomain.com"
recipients: "user@example.com"
```

**Use Cases:**
- Direct replies to a support mailbox
- Separate sending and receiving addresses
- No-reply scenarios with monitored reply-to address



## License

This integration is published under the GNU General Public License v3.0.



## Attribution

The Email Notifier is based on the Home Assistant SMTP integration. Thanks to onoffautomations for adding some new features.











## About sponsorship

If this Home Assistant integration is helpful to you, please consider supporting this project. Sponsorship helps keep the project going, improve features, and fix any issues that arise. Your contribution goes a long way in making the project better for everyone.

[![Sponsor me on GitHub](https://img.shields.io/badge/sponsor-me%20on%20GitHub-green)](https://github.com/sponsors/microteq)

Buy Me A Coffee