[APP][Pro] Mail Hook - Connect your inbox to your smart home automation

Mail Hook - Trigger Flows when new emails arrive via IMAP

This app triggers Homey Flows when new emails arrive in a configured IMAP inbox. It’s perfect for integrating incoming email events with smart home automations, such as notifying you when a specific sender messages you, running actions when a delivery notice arrives, or automating responses to important emails.


Triggers

A new email is received

Triggers when a new email arrives in the configured IMAP inbox. Provides the sender address, subject and body as tokens.

A new email is received on [account]

Same, but only for the account you pick.


Actions (Then)

  • Mark email as read / unread
  • Delete email (moves it to Trash)
  • Move email to a folder

Tap the tag icon in the Email reference field and pick the Email reference token from the trigger.
Move and delete make the reference unusable, so run them last: in an Advanced Flow after the other Mail Hook cards, in a standard Flow with a short delay.


Settings

Configure your IMAP server details:

  • Host (e.g. imap.gmail.com)
  • Port (usually 993 for IMAPS)
  • Username and password (Gmail, Yahoo and most other providers need an app password, not your normal password)
  • TLS toggle
  • Poll interval (seconds)

Includes a Test connection button to validate your IMAP credentials.


Tokens

  • Account name (work)
  • From (email) - sender@example.com
  • From (name) - John Doe
  • Email subject - Your package has been shipped
  • Email body - Dear customer, your order is on its way… (plain text, max 4096 characters)
  • Email reference - used by the Then cards

Examples

WHEN a new email is received, AND from_email contains “amazon”, THEN send notification “Package update received”

WHEN a new email is received, AND subject contains “security alert”, THEN turn on security lights

WHEN a new email is received, AND body contains “meeting tomorrow”, THEN add calendar reminder


Acknowledgements

Built using the Homey Apps SDK v3 and Node.js IMAP libraries.

Supported Languages

  • :uk: English
  • :netherlands: Dutch
  • :fr: French
  • :de: German

Donation

If you appreciate this app, contribute to future development by making a
paypal donate kopie

Or use QR Code:


Links

GitHub Repository: https://github.com/elmarkou/homey.mail.hook

Homey App Store: https://homey.app/en-us/app/mail.hook/Mail-Hook/

Documentation: https://github.com/elmarkou/homey.mail.hook#readme

Support: Issues · elmarkou/homey.mail.hook · GitHub

Screenshots



Usage

  1. Install the Mail Hook app on your Homey
  2. Configure your IMAP settings in the app settings
  3. Test the connection to ensure it works
  4. Create flows using the “A new email is received” trigger
  5. Use the provided tokens in conditions, notifications, or other actions

Done!

Release Notes

Latest 1.1.1
Test 1.2.1

changelog on app page

gives back a 404.

Correct its prod link buts its not approved yet. Changed to test url

Hi Elmar,

Please use English screenshots in English topics for all the non-Dutch out there.
In case you don’t want to change Homey’s language just to create screenshots,
Google Lens can translate text on images very well. An example, SE to EN:

test gives also back a 404

Fixed

The app is approved and Live!

Got a nice suggestion about multiple accounts. So this is now available for test:

And it’s live

hi @Elmar

could you please check not possible install on homey pro 2019 · Issue #1 · elmarkou/homey.mail.hook · GitHub

Hi @Elmar, same problem here not possible to install on Homey 2019, Software Version 13.1.2.

When I go to the app store and select my Homey to install, it says the app will be installed shortly, but nothing happens on my Homey. The app doesn’t install.

The other email app from Adam Noren don’t work anymore on Homey 2019, I use this longtime but don’t work anymore.

That app installs and works fine on my Pro 2019 v13.1.2 :man_shrugging:
So I think the issue is, it depends on the mail provider you use → at least Gmail doesn’t work (anylonger), even when using Googles’ “app passwords”.

Confirmed.
The Mail Hook indeed seems to get installed on my Pro 2019, the blue LED ring even turns for a while, but there’s no app to be found.

Hi Elmar,

Also posted as reply on the github issue;
After using the CLI homey app run command, this seems to quit the installation process on 2019 models:
✖ request to https://192-168-2-107.homey.homeylocal.com/api/manager/devkit/ failed, reason: unable to get local issuer certificate

It quits right after this error message.

Replied here

This is the most common fix for the Homey 2019.

• Tell them: “Unplug your Homey Pro from the power for at least 11 minutes. Do not just restart it via the app; it must be physically unplugged. This forces the security certificate to reset.”

Step 2: Use the Mobile App (Not a Browser)

If they are trying to click “Install” on a laptop browser, the browser’s security settings are likely blocking the request.

• Tell them: “Try to open the installation link on your phone instead of a computer, and make sure your phone is on the same Wi-Fi as the Homey. The mobile app handles security certificates differently than Chrome or Edge.”

Step 3: Disable “Private DNS” or VPN

If the user has a VPN active on their phone/computer, or a feature like “Private DNS” (common on Android), it will prevent the 192-168-x-x.homeylocal.com address from working.

• Tell them: “Turn off any VPNs or Ad-Blockers (like Pi-hole or AdGuard) temporarily while clicking Install.”

Curious what I’m doing wrong.

It’s a Yahoo account. Should I turn off TLS? Or, iis it some other user error?

Perhaps you didn’t generate an app password?

The TLS/SSL box should be ticked

Source:
https://help.yahoo.com/kb/SLN4075.html

So, I can’t use my normal credentials? I need a separate password?

Indeed. Follow the link I posted, it offers a link to generate an app password.

To compare: to use Gmail one also needs to use an app password.

New version 1.2.1 is available for test :slight_smile:

New “Then” cards (thx for the suggestion on GitHub):

  • Mark email as read / unread
  • Delete email (moves it to Trash)
  • Move email to a folder

How to use: the triggers now have an Email reference token. Tap the tag icon in the Email reference field of the Then card and pick that token.
Move and delete make the reference unusable, so run them last. In an Advanced Flow, connect them after the other Mail Hook cards. In a standard Flow, add a short delay.

Fixes:

  • Body token is now readable text (plain text, or HTML with the tags stripped) instead of raw MIME
  • Much lower memory use with big emails and attachments
  • No more duplicate triggers after saving the settings

Feedback welcome, here or on GitHub: Issues · elmarkou/homey.mail.hook · GitHub

Hi Elmar,

I have set-up some AVD’s with the Device Capabilities app, to have a Device card for each mailbox. And then I have some simple Python scripts stored on a Raspberry Pi, to fetch mailbox stats… and then some pretty crazy Flows to run the scripts, format the returned value and store it in the appropriate value of the AVD.

I saw your last post, and was wondering if you’d be interested in including something like this in your app?

For example:-

One of my mailbox AVD device cards, the button on the first tab just triggers the update stats Flow, if you want to update in between the intervals:

One of the Flows, that can either be started on a schedule, or by the update button:

And an example of the simple Python script to fetch the IMAP mailbox quota usage:

import imaplib
import datetime
import re

MAIL_SERVER = 'imap.example.nope'
USERNAME = 'email@example.nope'
PASSWORD = '***************************'
MAILBOX = 'Inbox'

try:
  imap = imaplib.IMAP4_SSL(MAIL_SERVER)
  imap.login(USERNAME, PASSWORD)
  imap.select(MAILBOX)

  mbox_quota_raw = imap.getquotaroot(MAILBOX)
  mbox_quota_cleaned = ' '.join([str(s) for s in mbox_quota_raw])
  reg_pat = r"(\d+)"
  mbox_quota_cleaned = re.search(reg_pat, mbox_quota_cleaned)
  if mbox_quota_cleaned:
    mbox_quota = (mbox_quota_cleaned.group())
  print (mbox_quota)

  imap.close()
  imap.logout()

except:
  print ("0")

Please excuse my coding… I am not a developer, my scripts were just written with lots of googling ha ha ha :rofl: I only include this an an example, so hopefully you are able to understand what I’m suggesting (I really hope my gibberish makes some kinda sense?)

I think this would make an awesome upgrade to your marvellous app… I use it a lot in my Flows :smiley:
I would very much like to hear what you think?

Thank you kindly good sir :saluting_face: for all your hard work on this app, and your consideration of new ideas.