From b56f3191989c74b558a8232b0abf9d2d17211a62 Mon Sep 17 00:00:00 2001 From: Jey Burrows <175012+jeyrb@users.noreply.github.com> Date: Wed, 25 Nov 2026 13:46:47 +0000 Subject: [PATCH 1/3] feat: reuse an Email Notifier connection for direct email When Home Assistant's SMTP integration isn't set up, the email transport takes its direct SMTP connection from the custom email_notifier integration (microteq/email_notifier or the Wheemer fork), whose config entry uses the same keys. Core SMTP is still preferred when both exist. Docs list the Wheemer fork, and the email transport page gains a checklist of what to look for in an email integration. Co-Authored-By: Claude Opus 5.5 --- .../supernotify/transports/email.py | 16 +++++--- docs/configuration/email.md | 2 +- docs/transports/email.md | 24 +++++++++++ .../transports/test_transport_email.py | 40 +++++++++++++++++++ 4 files changed, 76 insertions(+), 6 deletions(-) diff --git a/custom_components/supernotify/transports/email.py b/custom_components/supernotify/transports/email.py index 0bd87bdcb..c0e224fb1 100644 --- a/custom_components/supernotify/transports/email.py +++ b/custom_components/supernotify/transports/email.py @@ -106,6 +106,9 @@ # connection is configured here. "server" is smtp-specific; the rest match generic # homeassistant.const keys already imported above. HA_SMTP_DOMAIN = "smtp" +# the custom Email Notifier integration (microteq/email_notifier and its forks), a UI-configured +# SMTP alternative whose config entry uses the same keys as Home Assistant's smtp integration +EMAIL_NOTIFIER_DOMAIN = "email_notifier" SMTP_SEND_MESSAGE = "send_message" # Duplicates of the constants in `homeassistant.components.smtp.const`, to be kept aligned with it, # since importing from there loads the smtp integration and so needs its `aiosmtplib` requirement, @@ -252,12 +255,15 @@ def __init__(self, context: Context, transport_config: ConfigType | None = None) def _reuse_ha_smtp_connection(self) -> None: """No direct SMTP connection configured here; fall back to a configured HA smtp - integration entry, if any.""" - entry_data = self.hass_api.find_config_entry_data(HA_SMTP_DOMAIN) - if not entry_data: - _LOGGER.debug("SUPERNOTIFY No home assistant official smtp configuration to reuse") + integration entry, if any, or else a custom Email Notifier one.""" + for domain in (HA_SMTP_DOMAIN, EMAIL_NOTIFIER_DOMAIN): + entry_data = self.hass_api.find_config_entry_data(domain) + if entry_data: + break + else: + _LOGGER.debug("SUPERNOTIFY No smtp or email_notifier configuration to reuse") return - _LOGGER.info("SUPERNOTIFY Email transport reusing connection from HA smtp integration for direct SMTP sends") + _LOGGER.info("SUPERNOTIFY Email transport reusing connection from %s integration for direct SMTP sends", domain) self.host = entry_data.get(CONF_SERVER) self.port = entry_data.get(CONF_PORT, self.port) self.encryption = entry_data.get(CONF_ENCRYPTION, self.encryption) diff --git a/docs/configuration/email.md b/docs/configuration/email.md index a91f9a109..ee2d19f87 100644 --- a/docs/configuration/email.md +++ b/docs/configuration/email.md @@ -101,7 +101,7 @@ Amazon have more help on how to get their SMTP set up at [Set up email sending w ## Other Email Options * [ha-smtp](https://github.com/manjotsc/ha-smtp) - custom integration for SMTP that doesn't need YAML config -* [email-notifier](https://github.com/microteq/email_notifier) - Another UI-configured alternative SMTP integration +* [email-notifier](https://github.com/microteq/email_notifier) - Another UI-configured alternative SMTP integration, whose `email_notifier.send` action can send to any address. [Wheemer's fork](https://github.com/Wheemer/email_notifier) adds SMTP relays without a login. Supernotify can reuse its connection, see [Reusing the Home Assistant SMTP Integration Configuration](../transports/email.md#reusing-the-home-assistant-smtp-integration-configuration) * [MS365 Mail for Home Assistant](https://rogerselwyn.github.io/MS365-Mail/) - Microsoft based e-mail sending * Self Hosting * [Mail-in-a-Box](https://mailinabox.email) - Run on your own server, including receiving mail, running own webmail service diff --git a/docs/transports/email.md b/docs/transports/email.md index 5facb9ef5..1e3836c9a 100644 --- a/docs/transports/email.md +++ b/docs/transports/email.md @@ -240,6 +240,30 @@ In addition, all of the other `email` options are available, such as for tuning If no `connection` block is configured, this transport falls back to the connection details (server, port, encryption, username, password, `verify_ssl`, sender, sender name) from a configured [SMTP Integration](https://www.home-assistant.io/integrations/smtp/) config entry, so you don't have to duplicate credentials. This only applies to ConfigFlow (UI) based SMTP integration setups, not the legacy YAML `platform: smtp` style. Omit `connection` entirely to use this. +Where the Home Assistant SMTP integration isn't set up, the connection is taken in the same way from the +custom [Email Notifier](https://github.com/microteq/email_notifier) integration, or its fork by +[Wheemer](https://github.com/Wheemer/email_notifier). Only its connection is used, not the default recipients of its account. +For other ways of sending email, see [Other Email Options](../configuration/email.md#other-email-options). + +### What to Look For in an Email Integration + +Before relying on a custom email integration, check that: + +- **Sending doesn't hold up Home Assistant.** Connecting to the mail server, sending, testing the connection + during setup, and reading attachment files should all happen in the background. If they don't, Home Assistant + pauses while an email goes out, and the log has `Detected blocking call` warnings. +- **Each account's settings are kept apart.** With more than one account, two emails sent at the same time + should never mix up which login, sender or recipients are used. +- **A failed send is reported as an error.** If an email can't be sent, the action should fail, so that the + automation, or Supernotify's delivery record, shows it, rather than the failure appearing only in the log. +- **Home Assistant starts without the mail server.** If the mail server is down, startup shouldn't wait on it + or fail. +- **Attachments are limited to allowed folders.** Local files should only come from folders Home Assistant + allows, such as `allowlist_external_dirs`. Files downloaded from a URL should use Home Assistant's shared web + session, with a timeout. +- **Entity IDs don't change.** An account's entity ID shouldn't depend on the order in which accounts load. +- **It's maintained.** Look for tests, Home Assistant's `hassfest` validation, and recent fixes to reported issues. + ### Roadmap diff --git a/tests/components/supernotify/transports/test_transport_email.py b/tests/components/supernotify/transports/test_transport_email.py index 3d6728258..ea7cc62d7 100644 --- a/tests/components/supernotify/transports/test_transport_email.py +++ b/tests/components/supernotify/transports/test_transport_email.py @@ -666,6 +666,46 @@ def test_reuses_ha_smtp_connection_when_not_configured() -> None: assert uut.validate_action(None) is True +def test_reuses_email_notifier_connection_when_no_ha_smtp() -> None: + context = Mock(custom_template_path=None) + # as saved by the Wheemer fork, which leaves out blank credentials for a local relay + email_notifier_data = { + "server": "relay.example.com", + CONF_PORT: 25, + CONF_ENCRYPTION: "none", + "recipients": "someone@example.com", + CONF_SENDER: "notifier@example.com", + OPTION_SENDER_NAME: "Email Notifier", + "timeout": 15, + } + context.hass_api.find_config_entry_data.side_effect = lambda domain: ( + email_notifier_data if domain == "email_notifier" else None + ) + uut = EmailTransport(context, {}) + + assert [c.args[0] for c in context.hass_api.find_config_entry_data.call_args_list] == ["smtp", "email_notifier"] + assert uut.host == "relay.example.com" + assert uut.port == 25 + assert uut.encryption == "none" + assert uut.username is None + assert uut.password is None + assert uut.sender == "notifier@example.com" + assert uut.sender_name == "Email Notifier" + assert uut.validate_action(None) is True + + +def test_ha_smtp_connection_preferred_over_email_notifier() -> None: + context = Mock(custom_template_path=None) + context.hass_api.find_config_entry_data.side_effect = lambda domain: { + "server": f"{domain}.example.com", + CONF_SENDER: "ha@example.com", + } + uut = EmailTransport(context, {}) + + context.hass_api.find_config_entry_data.assert_called_once_with("smtp") + assert uut.host == "smtp.example.com" + + def test_existing_connection_not_overridden_by_ha_smtp() -> None: context = Mock(custom_template_path=None) uut = EmailTransport(context, SMTP_TRANSPORT_CONFIG) From 9c5b487d773d3f8ab0e5c94a0dc237720d52532a Mon Sep 17 00:00:00 2001 From: Jey Burrows <175012+jeyrb@users.noreply.github.com> Date: Wed, 25 Nov 2026 13:48:23 +0000 Subject: [PATCH 2/3] changelog for 2.19.1 Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 467949ad9..5bb9d59ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,15 @@ [Appliance Auto Notify](https://appliance-autonotify.rhizomatics.org.uk) will discover your dishwashers and ovens (limited to HomeConnect enabled in first releases) and power monitors, and set up progress bar style live activities automatically on phones. No automations, no actions. -[Camera Auto Notify](https://camera-autonotify.rhizomatics.org.uk/) automatic notifications from security cameras, so far supporting Frigate and ANPR2MQTT. No blueprints, no automations, no YAML. +[Camera Auto Notify](https://camera-autonotify.rhizomatics.org.uk/) automatic notifications from security cameras, so far supporting Frigate, OpenALPR and ANPR2MQTT. No blueprints, no automations, no YAML. + +# v2.19.1 + +## ✨ Enhancements +- *Email*: where Home Assistant's SMTP integration isn't set up, a direct SMTP email uses the connection of the custom [Email Notifier](https://github.com/microteq/email_notifier) integration, or of [Wheemer's fork](https://github.com/Wheemer/email_notifier), if set up from the UI. Only the connection, sender and sender name are used, not the default recipients of its account, see [Reusing the Home Assistant SMTP Integration Configuration](https://supernotify.rhizomatics.org.uk/latest/transports/email/#reusing-the-home-assistant-smtp-integration-configuration) + +## 📝 Other changes +- *Documentation*: a checklist of [what to look for in an email integration](https://supernotify.rhizomatics.org.uk/latest/transports/email/#what-to-look-for-in-an-email-integration) # v2.19.0 From ce58c74f3239c0e304811f749009ad2c42423a52 Mon Sep 17 00:00:00 2001 From: Jey Burrows <175012+jeyrb@users.noreply.github.com> Date: Wed, 25 Nov 2026 13:48:49 +0000 Subject: [PATCH 3/3] bump version to 2.19.1 Co-Authored-By: Claude Opus 5.5 --- custom_components/supernotify/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/supernotify/manifest.json b/custom_components/supernotify/manifest.json index abf3f89ab..c96c2e991 100644 --- a/custom_components/supernotify/manifest.json +++ b/custom_components/supernotify/manifest.json @@ -49,5 +49,5 @@ "aiofiles>=24.1.0" ], "single_config_entry": true, - "version": "2.19.0" + "version": "2.19.1" }