I had an open ticket with the help desk about achieving the same type of email aliasing/forwarding via a php script.
Initially, I used cpanel’s email filtering but was later advised by the help desk to use cpanel’s forwarding instead of filtering.
I have tried various strings in cpanel’s mail->mail manager->Forwarders section. The last session went something like this:
_______________________________________________________________
Add a new Forwarder
All email sent to mailpublisher@**** will now be redirected to
'pipe "/home/mydomain/www/mail.php"'
Forwarding Maintenance
Current Forwarders
mailpublisher@**** 'pipe"/home/mydomain/www/mail.php"'@****
________________________________________________________________
Needless to say, the forwarder as it is stored by cpanel with its automated appendage of @**** at the end of the pipe command does not work.
If filtering is not the answer and forwarding is not the answer, what is the answer to this problem?