Setting up email piping

OS type and version Ubuntu 20.04
Virtualmin version 7.5

I’m a bit confused on how to setup aliases to handle emails via a php script. I already have an email that is in use I want to connect it to our ticketing system so any emails sent to this address creates or updates a ticket.

What I did was added a forwarding on this email (from Edit Users) to Then I went to Edit Mail Aliases and added an alias for tickets and used the Feed to program option to point it to my php script.

For now, the script merely writes the mail to a log file, which didn’t happen. Problem is I don’t see any way to diagnose the problem. There is no mention of my php script in the apache access or error logs. Have I setup the aliases right? If so, how do I know if received the mail?

Have you check the mail log file if it happened i guess.

Yes I found something.

Jan 18 10:38:39 primary postfix/local[520087]: E564480726: to=<>, orig_to=<>, relay=local, delay=0.09, delays=0.02/0.01/0/0.06, dsn=5.3.0, status=bounced (Command died with status 1: "php /home/domain/public_html/vault/email-reciever.php". Command output: Could not open input file: /home/domain/public_html/vault/email-reciever.php )

I tried the same command from shell and it works fine.

Looks like I’ve been here before. Email piping to php. Could not open input file

I could never work this thing out.

I tested, and finally got it worked for me anyway. I put the php at /usr/local/bin so postfix has permission in the directory. Put ownership on the file as postfix. Make sure executable. Added the line “#! /usr/bin/php” first line of the php, so don’t need the php command to execute. If php script is writing to a file make sure the file writable.

Thanks for taking the time to try it out. It worked for me too but its highly impractical. Would it be possible to have it work if the handler file is in one of the directory? I tried to change the owner and group to postfix but that didn’t work.

Can’t the php script to move what you want to the public_html location?

It doesn’t work in public_html directory. Does it work for you?

No that why I moved to /usr/local/bin .

Do you think this is a virtualmin problem?

No this is a linux permissions issue. You need to google the issue. Surely someone else has tried this.