# Email - Trigger flows based on incoming emails

**URL:** <https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337>\
**Category:** Apps\
**Created:** [February 20, 2021, 8:02am UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337 "2021-02-20T08:02:11Z")\
**Posts on this page:** 20\
**Page:** 4

<div class="post-metadata">

**Author:** ![lukenukemmp3](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/lukenukemmp3/32/91808_2.png) [@lukenukemmp3](https://community.homey.app/u/lukenukemmp3)\
**Post date:** [April 25, 2024, 7:17am UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/65 "2024-04-25T07:17:55Z")

</div>

I wrote Adam Noren about this and contacted Athom. While Mr Noren didn’t react in any way, Athom is just being Athom and gave me a standard mail response.

So I thought about how I can achieve this in other ways. I want to share my alternatives with you.

**1. IFTTT**  
I used the IFTTT Mail integration and the IFTTT-Homey-App for a long time. It works. Not fast, not on every mail (paypal mails eg seems to be filtered out), but it works. But due to the lag and not every mail being delivired, it was not reliable enough for my purpose.

**2. Webhooks**  
In my case I used the mails as a transmitting service for information. So I chose to do this with a complete other method: a webhook called by a PHP-script with curl and all the tags I want.  
Here is the PHP-script:

$url = ‘[https://webhook.homey.app/YOURWEBHOOKTOKEN/THEHOMEYTAG?tag=‘.rawurlencode($data1).’\_](https://webhook.homey.app/YOURWEBHOOKTOKEN/THEHOMEYTAG?tag='.rawurlencode($data1).'_)’. rawurlencode($data2).‘\_’.rawurlencode($data3);  
$ch = curl\_init();  
curl\_setopt($ch, CURLOPT\_URL, $url);  
curl\_setopt($ch, CURLOPT\_CUSTOMREQUEST, “GET”);  
curl\_setopt($ch, CURLOPT\_RETURNTRANSFER, true);  
curl\_exec($ch);  
curl\_close($ch);

The “\_” serves as seperator of tags I want to read out differently in homey. The $data-variables can be anything you want. Everything gets encoded in rawurl, therefore nothing gets lost. This must be reverted in Homey, so you have to split the string and decode it and write it in variables to use after in the flow. This is my script (Run Script with Input) in Homey, following the logic card “Webhook event [THEHOMEYTAG] has been received”:

// decode & split  
let input = (args[0]);  
input = decodeURI(input);  
let array = input.split(“\_”);  
let one = array[0].trim();  
let two = array[1].trim();  
let three = array[2].trim();

// create Homey-Tags  
await tag(‘TAG1’, one);  
await tag(‘TAG2’, two);  
await tag(‘TAG3’, three);

TAG1, TAG2 and TAG3 are the tags that can be used in flows from then on. You have to start the script once, to create the tags and then they will be available in the tag-list in other flow-cards.

I know, not every usecase of the mail-app can be replaced with the PHP-webhook-method, but maybe it will help some of you. There are also several ways on different systems to trigger a PHP-script, when a mail is received, but I haven’t dived deep in there yet.

**3. Rebuilding another App for incoming Mails**  
I just have started to get into the app-building process for Homey. Once I’m able to get there, I will try to create another app for this purpose, called _Mailtrigger_ or something like that. But please be patient as this is just a hobby and I have to use my limited free time for this.

Please feel free to ask any questions about this.

---

<div class="post-metadata">

**Author:** ![ZeroSugar](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/zerosugar/32/34211_2.png) [@ZeroSugar](https://community.homey.app/u/ZeroSugar)\
**Post date:** [September 16, 2024, 8:05am UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/66 "2024-09-16T08:05:09Z")

</div>

Very strange…as soon as the mail arrives (i assume that’s when it happens), the “email cards” are greyed out. After some time they go back to normal 🙄

 ![ReceiveMail](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/d/1d98847c534f758d3ea56815804a8349a3b8a766.jpeg)

The flow is not executed.  
Any idea what this might be?

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [September 16, 2024, 8:25am UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/67 "2024-09-16T08:25:48Z")

</div>

> [@ZeroSugar](#):
>
> Any idea what this might be?

The app crashes.

---

<div class="post-metadata">

**Author:** ![ZeroSugar](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/zerosugar/32/34211_2.png) [@ZeroSugar](https://community.homey.app/u/ZeroSugar)\
**Post date:** [September 16, 2024, 10:32am UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/68 "2024-09-16T10:32:36Z")

</div>

Oeps…that’s not good.

---

<div class="post-metadata">

**Author:** ![Manuel\_Sentis](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/manuel_sentis/32/113078_2.png) [@Manuel\_Sentis](https://community.homey.app/u/Manuel_Sentis)\
**Post date:** [November 11, 2024, 11:01am UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/69 "2024-11-11T11:01:21Z")

</div>

bonjour à tous est-ce que quelqu’un à réussi à faire fonctionner cette appli.  
je n’arrive pas avec une adresse mail @gmail.com ou outlook  
dommage qu’Homey ne fasse pas de support.

---

<div class="post-metadata">

**Author:** ![iMike](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/imike/32/12410_2.png) [@iMike](https://community.homey.app/u/iMike)\
**Post date:** [December 14, 2024, 10:46am UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/70 "2024-12-14T10:46:37Z")

</div>

Does anybody now what “Host” and “port number” I had to use for my [hotmail.com](http://hotmail.com) account? I used “[map-mail.outlook.com](http://map-mail.outlook.com)” and “993” but I get the message “Timed out while authenticating with server”. When I check the box “TLS” I get the message “LOGIN failed”.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [December 14, 2024, 10:32pm UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/71 "2024-12-14T22:32:23Z")

</div>

Hi Mike,

If you haven’t already, first enable _IMAP_ for your mailbox  
[https://go.microsoft.com/fwlink/?linkid=875424](https://go.microsoft.com/fwlink/?linkid=875424)

Then, configure the app with these settings:

 ![1000038878](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/3/835c81a70d87eee93451bde7c696be673c1a8054.jpeg)

 ![1000038874](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/e/2/e2cbb2e3df826c79fac69ff16f9508ba3db1ae2c.jpeg)

 ![1000038877](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/e/9/e9cabc56f39770c01909773abae93e93eb9b4781.jpeg)

[Source](https://support.microsoft.com/en-us/office/pop-imap-and-smtp-settings-for-outlook-com-d088b986-291d-42b8-9564-9c414e2aa040)

---

<div class="post-metadata">

**Author:** ![iMike](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/imike/32/12410_2.png) [@iMike](https://community.homey.app/u/iMike)\
**Post date:** [January 5, 2025, 5:08pm UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/72 "2025-01-05T17:08:46Z")

</div>

Hi Peter\_Kawa, Thanks for your response. Due to personal issues I did not respond earlier, apologies for that. I will work on your comments.

---

<div class="post-metadata">

**Author:** ![Kam](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kam/32/121058_2.png) [@Kam](https://community.homey.app/u/Kam)\
**Post date:** [January 5, 2025, 10:08pm UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/73 "2025-01-05T22:08:55Z")

</div>

Hello lukenukemmp3, how are you?

I am a new Homey Pro (2023 release) user and I stumbled upon this post because the original e-mail application by Adam Norén isn’t fully functioning for me. Every time the start block triggers, the card turns gray and is unavailable, with the following explanation - This card is unavailable because the app or device that it belongs to might have been removed.

Anyway, I am extremely interested in your second method since I wanted this option for my job. I, however, am very green to coding. Could you please assist me into implementing your code into my Homey? Also, do you have an update in your Mailtrigger app?

---

<div class="post-metadata">

**Author:** ![lukenukemmp3](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/lukenukemmp3/32/91808_2.png) [@lukenukemmp3](https://community.homey.app/u/lukenukemmp3)\
**Post date:** [January 5, 2025, 11:40pm UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/74 "2025-01-05T23:40:48Z")

</div>

Hey Kam,

thank you for your kind words!  
The unfortunate words first: I did not have found any time on building the Mailtrigger-App. Maybe I will some time, but not now.

Regarding your question on my “second” method AKA the webhooks: may I ask you, what it is you try to achieve? Can you tell me any details on your task without personal information? That would be very helpful and I would be glad to help you out!

---

<div class="post-metadata">

**Author:** ![Kam](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kam/32/121058_2.png) [@Kam](https://community.homey.app/u/Kam)\
**Post date:** [January 6, 2025, 4:36am UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/75 "2025-01-06T04:36:51Z")

</div>

Thank you for the swift response. I am trying to do what Adam’s initial app accomplished. I want to start a flow with “if” block, checking my Gmail inbox to see if I received an email from a specific email address. Furthermore, I also included a screenshot of my current flow, realized it was no longer functional ☹

 ![image_2025-01-05_233706710](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/8/089f8179f07b400f7acef226be7f773ad4c687a1.png)

---

<div class="post-metadata">

**Author:** ![lukenukemmp3](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/lukenukemmp3/32/91808_2.png) [@lukenukemmp3](https://community.homey.app/u/lukenukemmp3)\
**Post date:** [January 6, 2025, 7:59am UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/76 "2025-01-06T07:59:49Z")

</div>

Okay, do you got the opportunity to fire a PHP-script when the mail is received? From where is the mail send? Can you execute the PHP-script instead of sending the mail?  
Otherwise I don’t know, how the PHP-method could help here.

Maybe you can use IFTTT instead. Create a forwarding-rule for your specific sender and trigger an IFTTT-automation for incoming mails to start a Homey flow. Set up the IFTTT-App in Homey and use the If-card in a flow to start the computer. This will have a bit of a latency but it is working.

---

<div class="post-metadata">

**Author:** ![Kam](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kam/32/121058_2.png) [@Kam](https://community.homey.app/u/Kam)\
**Post date:** [January 7, 2025, 3:32am UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/77 "2025-01-07T03:32:16Z")

</div>

I would prefer to stay away from services like IFTTT because of latency. Here’s about why I want to set up this type of note. I have a job where I get notified, by email only, of available tasks. These tasks are also available to our coworkers. That means, each task is available only to the first person who accepts it, AKA sees the email. Maybe that’s fair or not, discussion for a different forum.

First, how do I fire a PHP-script when the mail is received? The email is sent from [outlook.com](http://outlook.com) to [gmail.com](http://gmail.com).  
I apologize for the countless elementary questions when it comes to scripts, but I’m extremely unfamiliar when it comes to coding anything.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [January 7, 2025, 5:53pm UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/78 "2025-01-07T17:53:24Z")

</div>

@AdvaLa please remove the [App][Pro] part of the title.  
This is reserved to use (and identify) for actual app topics. Thx.

---

<div class="post-metadata">

**Author:** ![Stefan\_Beck](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/stefan_beck/32/80078_2.png) [@Stefan\_Beck](https://community.homey.app/u/Stefan_Beck)\
**Post date:** [January 7, 2025, 7:27pm UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/79 "2025-01-07T19:27:23Z")

</div>

Hello everyone, do any of you use the APP Email? I have connected my email account. When an email arrives with the subject as an example test, a flow should start. When an email arrives, the app reports an error and crashes. who can help?

 ![grafik](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/7/c/7c0c7734d31af7faa170ad80402015fc753b30b2.png)  
 ![grafik](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/2/a238773819a7dd308781dcfb3f7683608b4e32c7.png)

Text:TypeError: Cannot set property errored of # which has only a getter  
at new MessageSplitter (/app/node\_modules/mailsplit/lib/message-splitter.js:28:22)  
at new MailParser (/app/node\_modules/mailparser/lib/mail-parser.js:132:25)  
at module.exports (/app/node\_modules/mailparser/lib/simple-parser.js:29:18)  
at EventEmitter. (/app/app.js:76:17)  
at EventEmitter.emit (node:events:517:28)  
at Parser. (/app/node\_modules/imap/lib/Connection.js:220:24)  
at Parser.emit (node:events:517:28)  
at Parser.\_resUntagged (/app/node\_modules/imap/lib/Parser.js:196:10)  
at Parser.\_parse (/app/node\_modules/imap/lib/Parser.js:137:16)  
at Parser.\_tryread (/app/node\_modules/imap/lib/Parser.js:82:15)

---

<div class="post-metadata">

**Author:** ![Stefan\_Beck](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/stefan_beck/32/80078_2.png) [@Stefan\_Beck](https://community.homey.app/u/Stefan_Beck)\
**Post date:** [January 7, 2025, 5:36pm UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/80 "2025-01-07T17:36:18Z")

</div>

Hello everyone, do any of you use the APP Email? I have connected my email account. When an email arrives with the subject as an example test, a flow should start. When an email arrives, the app reports an error and crashes. who can help?

 ![grafik](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/7/c/7c0c7734d31af7faa170ad80402015fc753b30b2.png)  
 ![grafik](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/2/a238773819a7dd308781dcfb3f7683608b4e32c7.png)

Text:TypeError: Cannot set property errored of # which has only a getter  
at new MessageSplitter (/app/node\_modules/mailsplit/lib/message-splitter.js:28:22)  
at new MailParser (/app/node\_modules/mailparser/lib/mail-parser.js:132:25)  
at module.exports (/app/node\_modules/mailparser/lib/simple-parser.js:29:18)  
at EventEmitter. (/app/app.js:76:17)  
at EventEmitter.emit (node:events:517:28)  
at Parser. (/app/node\_modules/imap/lib/Connection.js:220:24)  
at Parser.emit (node:events:517:28)  
at Parser.\_resUntagged (/app/node\_modules/imap/lib/Parser.js:196:10)  
at Parser.\_parse (/app/node\_modules/imap/lib/Parser.js:137:16)  
at Parser.\_tryread (/app/node\_modules/imap/lib/Parser.js:82:15)

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [January 7, 2025, 5:51pm UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/81 "2025-01-07T17:51:32Z")

</div>

[@moderators](https://community.homey.app/groups/moderators) pls move to existing topic about issue: [[App][Pro] Email - Trigger flows based on incoming emails](https://community.homey.app/t/app-pro-email-trigger-flows-based-on-incoming-emails/43337)

---

<div class="post-metadata">

**Author:** ![Kam](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kam/32/121058_2.png) [@Kam](https://community.homey.app/u/Kam)\
**Post date:** [January 8, 2025, 9:00pm UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/82 "2025-01-08T21:00:14Z")

</div>

This application seems to not properly function.

---

<div class="post-metadata">

**Author:** ![lukenukemmp3](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/lukenukemmp3/32/91808_2.png) [@lukenukemmp3](https://community.homey.app/u/lukenukemmp3)\
**Post date:** [January 9, 2025, 11:13am UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/83 "2025-01-09T11:13:12Z")

</div>

Hey Kam,

please excuse my late response, there has been some movement of posts which lead to difficulties finding our conversation again - at least for me.

Is the mail from outlook send automatically? I thought you can execute the PHP-script instead of sending an e-mail. I do need more information on your enviroment, because I’m not sure, if I understand your topic correctly. Thank you in advance.

---

<div class="post-metadata">

**Author:** ![Kam](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kam/32/121058_2.png) [@Kam](https://community.homey.app/u/Kam)\
**Post date:** [January 9, 2025, 9:24pm UTC](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337/84 "2025-01-09T21:24:09Z")

</div>

Totally no problem on the response - we’re all human 😃

I set up the Outlook e-mail to be forwarded to Gmail. How do I execute the PHP-script instead of sending an e-mail?

[Previous page](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337.md?page=3)

[Next page](https://community.homey.app/t/email-trigger-flows-based-on-incoming-emails/43337.md?page=5)
