Cannot pipe email to php script...

Hi all,

I can’t seem to get this one to work and it is boggling my brain… What I’m trying to so is as the subject says, trying to pipe and email to a php script that is designed to take the email information and process it.

In the email aliases field I have selected the email alias “support” and configured the “Feed to program” setting with “/home/”. To test I have created a test.php file that emails me once the script has been executed. So I send an email to and get this in the logs:

“temporary failure. Command output: local: fatal: execvp /home/ Permission denied”

I’ve tried all manor of permissions variations, but nothing…

When I do a “php -q /home/” , the test script I get the script output and an email in my inbox, so I know the script is working.

Somehow I think php needs to be piped to and the pipe data passed onto the script. Everywhere I look there is no mention of this.

Any help would be much appreciated.


Does it by chance work if you use the same command line that you use when manually running it?

That is, can you use “php -q /home/” in the “Feed to program”?


Thanks or the reply. Tried that and get the output: (expanded from Command died with status 1: “php -q
/home/”. Command
output: Could not open input file:

I’m stumped. Thoughts?


Okay, just to ask a silly question – are you super-sure that the path you’re using to test.php is correct?

If you run “ls -l home/”, does that work and show you info about the file?


Thanks, even silly questions appreciated.

Shows the file info. -rwxrwxrwx permissions and correct user and group…

I would be interested to see if this is working successfully on another Virtualmin server.

I even tried using a shell script… Damn nabbit.


Okay, first thing I’d do is run a “chmod 755” on that script – I understand you were just troubleshooting, but it definitely doesn’t need to be 777, and you don’t want random people being able to edit that :slight_smile:

Second –

While this shouldn’t be an issue, as procmail should be running as your username here – perhaps we can try this as an experiment.

If you were to make the directories leading up to your script executable, you could rule out an odd permissions issue… something like:

chmod +x /home/ /home/

That worked! The main script I’m working with is encoded with sourceguardian and doesn’t seem to be doing anything, but my test script took the pipe stdin of the email and emailed the contents to another address, so I know that it’s working…

Many thanks for your help Eric!


One more quick question…

I did a few other tests, only to find that when an email is piped to a file the user and group is set to nobody:nobody… Can that be set per user? Seems a bit odd to me as permissions would need to be very lax if I was to save emails into a users directory…



Well, the issue you’re seeing is fairly a-typical… it sounds like something else may be going awry.

How did you go about installing Virtualmin – had you used the script? And what distro are you using?

Lastly, what does this command show:

grep mailbox_command /etc/postfix/

Installed via script on a fresh Centos 5.3 install… Hmmmm…

grep mailbox_command /etc/postfix/

The mailbox_command parameter specifies the optional external

Unlike other Postfix configuration parameters, the mailbox_command

#mailbox_command = /some/where/procmail
#mailbox_command = /some/where/procmail -a “$EXTENSION”

has precedence over the mailbox_command, fallback_transport and

mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME


Is anyone else having problems with piping? I’ve got it working, but it seems hazardous to allow such lax permissions.


I know this post is getting old, but just wanted to acknowledge that after struggling with getting email piping to work for a whole day, stumbling across this old post and following this suggestion:

chmod +x /home/ /home/

…got it working!


If you are trying to save some time you might consider using a hosted service for the email piping. Another reason this can be helpful is that it handles the email parsing as well. You might checkout (free) or (premium) to speed things up.

Command died with status 1: “php -q /home/mydomain/public_html/admin/pipe/pipe.php”.
Command output: Could not open input file: /home/mydomain/public_html/admin/pipe/pipe.php

I followed the tips suggested above, but the alias doesn’t send or better the pipe.php was not executed,
if I run the script in terminal php -q /home/mydomain/public_html/admin/pipe/pipe.php
I have Site error: the file xxxx need ioncube loader…bla bla bla
Whmcs have been installed by Virtualmin, ioncube is loaded, the file .so is in the folders…

What’s up ?


You may need to include the path to your PHP config on the command line… something like this:

PHPRC=/home/mydomain/etc/php5 php -q /home/mydomain/public_html/admin/pipe/pipe.php

Otherwise it would default to the system-wide PHP config.


An error comes out when you save the Alias destinations:

“Failed to save alias : ‘1’ is not a valid program or does not exist”

the same error come out if I try to write the command with “|” as 1st character, “| php -q /home/mydomain/public_html/admin/pipe/pipe.php”

PHPRC=/home/mydomain/etc/php5 php -q /home/mydomain/public_html/admin/pipe/pipe.php

is wrote right ?
Or Virtualmin doesn’t accept the string because want it write differently , or for what ??
The pipe setting is for the Whmcs Ticket System

Eric need again your touch !

To use a pipe, you’d want to go into the “Advanced mode” tab when creating the alias. Then, select “Feed to Program” in the dropdown.

Using that option should allow you to pipe to your script.


in “Feed to Program” I have the error, as I told you, I have simply modified the string adding the custom php, adding “PHPRC=/home/mydomain/etc/php5” cause the error,
if I write only “php -q /home/mydomain/public_html/admin/pipe/pipe.php” that string is accepted, but not well executed, the email sender receive an error from the mail server “Command output: Could not open input file: /home/mydomain/public_html/admin/pipe/pipe.php”
I have tried to add in the main php.ini the reference to ioncube, but I receive an ioncube error when I execute the script.
If I try to run in terminal, “PHPRC=/home/mydomain/etc/php5 php -q /home/mydomain/public_html/admin/pipe/pipe.php”, I receive this error:

PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/’ - /usr/lib64/php/modules/ cannot open shared object file: No such file or directory in Unknown on line 0