# Pipe emails into cakePHP

**URL:** <https://discourse.cakephp.org/t/pipe-emails-into-cakephp/8991>\
**Category:** Need Help\
**Tags:** help\
**Created:** [February 9, 2021, 10:35pm UTC](https://discourse.cakephp.org/t/pipe-emails-into-cakephp/8991 "2021-02-09T22:35:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mtbrandall](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@mtbrandall](https://discourse.cakephp.org/u/mtbrandall)\
**Post date:** [February 9, 2021, 10:35pm UTC](https://discourse.cakephp.org/t/pipe-emails-into-cakephp/8991/1 "2021-02-09T22:35:01Z")

</div>

Hi,

Im looking at piping incoming emails into cakePHP

I have tried setting up a Console command to make it work but i cant seem to make it work.

Any help to get this working would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [February 9, 2021, 11:55pm UTC](https://discourse.cakephp.org/t/pipe-emails-into-cakephp/8991/2 "2021-02-09T23:55:23Z")

</div>

It generally works better if you share specifically what you’ve tried (e.g. code). Otherwise, you’re not really asking for help fixing what you have, you’re asking people to do all the work for you.

---

<div class="post-metadata">

**Author:** ![raul338](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/raul338/32/69_2.png) [@raul338](https://discourse.cakephp.org/u/raul338)\
**Post date:** [February 10, 2021, 12:36am UTC](https://discourse.cakephp.org/t/pipe-emails-into-cakephp/8991/3 "2021-02-10T00:36:47Z")

</div>

you mean to setup an emails server that calls a command for each incoming email?

something like

```auto
cat temp_mail.msg | /app/bin/cake parse_mail

```

if that so, you can parse the console input with [hfig/MAPI](https://github.com/hfig/MAPI)

However, i would create a command that reads an IMAP box periodically, with [ddeboer/imap](https://github.com/ddeboer/imap), i would work with external mails providers.

---

<div class="post-metadata">

**Author:** ![mtbrandall](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@mtbrandall](https://discourse.cakephp.org/u/mtbrandall)\
**Post date:** [February 10, 2021, 3:58pm UTC](https://discourse.cakephp.org/t/pipe-emails-into-cakephp/8991/4 "2021-02-10T15:58:22Z")

</div>

Code is here [Mtbrandall's Pastebin - Pastebin.com](https://pastebin.com/u/mtbrandall/1/B8jiWbBA)

When i rung from the SSH terminal it works fine but whenever i send via email the emails get bounced with an error  
This message was created automatically by mail delivery software.

```
A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

pipe to |/home/cobaltholidays/[#######/public_html/bin/cake.php](http://########public_html/bin/cake.php) ticket
generated by [debug@cobaltholidays.co.uk](mailto:debug@cobaltholidays.co.uk)
local delivery failed

The following text was generated during the delivery attempt:

------ pipe to |/home/cobaltholidays/[pontus.cobaltholidays.co.uk/public_html/bin/cake.php](http://#######/public_html/bin/cake.php) ticket
generated by [debug@cobaltholidays.co.uk](mailto:debug@cobaltholidays.co.uk) ------

<br />
<b>Notice</b>: Undefined variable: argv in <b>/home/cobaltholidays/[#######/public_html/bin/cake.php](http://#######/public_html/bin/cake.php)</b> on line <b>12</b><br />
<br />
<b>Fatal error</b>: Uncaught TypeError: Argument 1 passed to Cake\Console\CommandRunner::run() must be of the type array, null given, called in /home/cobaltholidays/[######/public_html/bin/cake.php](http://#######public_html/bin/cake.php) on line 12 and defined in /home/cobaltholidays/[######/public_html/vendor/cakephp/cakephp/src/Console/CommandRunner.php:130](http://pontus.cobaltholidays.co.uk/public_html/vendor/cakephp/cakephp/src/Console/CommandRunner.php:130)
Stack trace:
#0 /home/cobaltholidays/[######/public_html/bin/cake.php(12)](http://#####/public_html/bin/cake.php(12)): Cake\Console\CommandRunner-&gt;run(NULL)
#1 {main}
thrown in <b>/#######/public_html/vendor/cakephp/cakephp/src/Console/CommandRunner.php](http://#########/public_html/vendor/cakephp/cakephp/src/Console/CommandRunner.php)</b> on line <b>130</b><br />
```

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [February 10, 2021, 7:52pm UTC](https://discourse.cakephp.org/t/pipe-emails-into-cakephp/8991/5 "2021-02-10T19:52:39Z")

</div>

What is your command line when you run it successfully from the terminal? And what exactly is the configuration you’re using in your mail server setup to pipe it?

---

<div class="post-metadata">

**Author:** ![mtbrandall](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@mtbrandall](https://discourse.cakephp.org/u/mtbrandall)\
**Post date:** [February 10, 2021, 9:15pm UTC](https://discourse.cakephp.org/t/pipe-emails-into-cakephp/8991/6 "2021-02-10T21:15:45Z")

</div>

via ssh

> bin/cake ticket

via cPanel Forwarder

> |/home/cobaltholidays/pontus.cobaltholidays.co.uk/public\_html/bin/cake.php ticket

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [February 10, 2021, 10:23pm UTC](https://discourse.cakephp.org/t/pipe-emails-into-cakephp/8991/7 "2021-02-10T22:23:47Z")

</div>

The former uses `bin/cake`, the latter uses `bin/cake.php`. Did you try the forwarder without the `.php`?

---

<div class="post-metadata">

**Author:** ![mtbrandall](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@mtbrandall](https://discourse.cakephp.org/u/mtbrandall)\
**Post date:** [February 11, 2021, 3:21pm UTC](https://discourse.cakephp.org/t/pipe-emails-into-cakephp/8991/8 "2021-02-11T15:21:18Z")

</div>

i had tried without however that still didnt work.  
i have now got it working to the point that the emails are recevied. However it still bounces an email back with a fail.
