External integration - IMAP Mail

Hi everyone!

Many devices and services can only notify via email: the NAS, the alarm, the carrier… Gladys already knew how to send emails with the SMTP integration. Here’s the opposite: IMAP Mail, so that received emails trigger scenes.

What it does

  • Up to 3 mailboxes (Gmail, Outlook, iCloud or personal server) and 5 folders per mailbox, the first one followed in real-time.
  • A « Mail received » trigger, filterable by sender, domain or folder, and a « Keyword in the subject » trigger for keywords entered in the configuration. The sender, subject and a short excerpt (disableable) are usable in the scene messages.
  • A counter of unread emails per mailbox, usable in conditions and in graphs.
  • Actions: read the number of unread emails, mark as read the email that triggered the scene.
  • A « Recent emails » widget (sender, subject, time; never the content).

Privacy side: nothing is marked as read when reading, no email content is stored, and emails already present at first startup do not trigger anything.

The cool thing

Keyword « delivered » in the subject → Telegram message with the email subject
Email received from the NAS alert → red light, notification, then mark as read
At 7:30 a.m. → « You have N unread emails »

Installation

Gladys 5.1 minimum.

It will arrive in the store at the next indexer update. In the meantime: Integrations → Install from GitHub, with the address GitHub - guim31/gladys-imap: IMAP mailboxes in Gladys Assistant: scene triggers on new emails and unread counters · GitHub

  1. Fill in a block: server, username, password (for Gmail and Outlook, an application password).
  2. Test the connection, then add the device from the Discovery tab.

Honest small reservations: no OAuth2, no attachments, and real-time only concerns the first folder. It has been tested against a real IMAP server in a container (emails received in less than a second, reconnection, wrong password, rejected certificate) under Gladys’ sandbox conditions, but not yet with major providers: if you try it with Gmail or Outlook, let me know.

Coded with the help of Claude Code.

Repository: GitHub - guim31/gladys-imap: IMAP mailboxes in Gladys Assistant: scene triggers on new emails and unread counters · GitHub

Your feedback is welcome :slight_smile: