Mail Server Checker for Home Assistant
Monitor Your Email Servers with Ease
Keeping your email servers running smoothly is critical, whether you’re managing a business or simply staying connected. As part of my journey in creating tools that simplify life, I’ve recently upgraded my Home Assistant Email Server Checker Integration, and I’m excited to share what’s new!
This custom integration allows you to monitor the status of your IMAP and SMTP servers directly from your Home Assistant dashboard. Let’s dive into the details of the improvements and why you might want to give it a try.
What Does the Email Server Checker Do?
The integration performs real-time checks on your email servers:
• IMAP Server Check: Ensures that your incoming mail server is accessible and working correctly.
• SMTP Server Check: Validates that your outgoing mail server can send emails.
In case of any issues, the integration updates the status and can even trigger notifications via Home Assistant automations.
What’s New in the Latest Version?
With the latest upgrade, I’ve focused on improving usability, reliability, and debugging capabilities. Here’s what’s been added:
1. Better Error Handling
Instead of generic errors, the integration now provides detailed and actionable messages for:
• IMAP-specific issues like authentication failures.
• SMTP-specific errors such as connection timeouts.
2. Enhanced Logging
Logs now include:
• Connection attempts for both IMAP and SMTP servers.
• Clear success and failure messages.
This makes debugging a breeze if something goes wrong.
3. Additional Attributes
The integration now displays more information:
• The IMAP and SMTP server hostnames.
• The timestamp of the last successful or failed check.
4. Dynamic State-Based Icons
A quick glance at the UI tells you if all is well:
• Green Check (mdi:check-circle) for success.
• Red Alert (mdi:alert-circle) for errors.
5. Clean Code, Easier Maintenance
For those who like to tinker:
• The code is modular, with separate methods for IMAP and SMTP checks.
• Default ports for IMAP (993) and SMTP (465) are now constants.
How to Install via HACS
Follow these simple steps to add the Email Server Checker to your Home Assistant instance:
1. Add the Repository
1. Open HACS in Home Assistant.
2. Navigate to Integrations > … > Custom Repositories.
3. Add this repository URL:
https://github.com/tvdsluijs/hass_mail_server_checker
4. Set the category to Integration.
2. Install the Integration
1. Search for “Email Server Checker” in HACS under Integrations.
2. Click Install and restart Home Assistant.
3. Configure the Integration
Add the following to your configuration.yaml:
sensor:
- platform: mail_server_checker
sensors:
my_email_server:
friendly_name: "My Email Server"
imap_server:
host: mail.example.com
port: 993
smtp_server:
host: smtp.example.com
port: 465
username: !secret email_username
password: !secret email_password
Restart Home Assistant, and the sensor will appear in your dashboard.
Use Case: Automations
Combine this integration with Home Assistant automations to stay informed:
• Send a notification to your phone if a server goes down.
• Trigger a backup MX server if the primary server fails.
Here’s an example:
automation:
- alias: "Notify on Email Server Error"
trigger:
- platform: state
entity_id: sensor.my_email_server
to: "Error"
action:
- service: notify.mobile_app_your_device
data:
title: "Email Server Alert"
message: >
{{ state_attr('sensor.my_email_server', 'imap_server') }} is down.
Wrapping Up
This upgraded integration brings peace of mind to anyone relying on email servers. Whether you’re a developer, sysadmin, or tech enthusiast, monitoring your infrastructure has never been this easy.
Have feedback or ideas? Let me know in the comments or on GitHub. Let’s make Home Assistant even smarter together!
Cheers,
Theo van der Sluijs
Creator of Smart Solutions, Tech Enthusiast, and Home Automation Nerd