Email forwarding Pipe to a Program

Can you add a feature in email forwarding “Pipe to a Program” like as cPanel?

For WHMCS I use whmcs piping option. It would be better if you add this option in Email forwarding.

I need this too.

+1

Also, +1 to this needs a proper gui support for those switching from cPanel > cyberpanel who are running osticket whmcs etc which uses email piping for support tickets.
https://docs.whmcs.com/Email_Piping

Looks like it should be doable with postfix which is what Cyberpanel uses for the email server.
https://www.anthonyhawk.com/Linux/osticket-pipe-emails-postfix.html

You may have some luck with this method.

for example from cPanel I’m migrating a whmcs from.

How it looks in cPanel

[root@vcloud ~]# cat /etc/valiases/example.com
billing@example.com: “|/opt/cpanel/ea-php73/root/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
sales@example.com: “|/opt/cpanel/ea-php73/root/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
sharedsupport@example.com: “|/opt/cpanel/ea-php73/root/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
support@example.com: “|/opt/cpanel/ea-php73/root/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
vpnsupport@example.com: “|/opt/cpanel/ea-php73/root/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
vpssupport@example.com: “|/opt/cpanel/ea-php73/root/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”

Cleaned up with proper paths in cyberpanel
billing@example.com: “|/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
sales@example.com: “|/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
sharedsupport@example.com: “|/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
support@example.com: “|/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
vpnsupport@example.com: “|/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
vpssupport@example.com: “|/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”

Setup aliases in /etc/postfix/virtual

billing@example.com billingalias
sales@example.com salesalias
sharedsupport@example.com sharedsupportalias
support@example.com supportalias
vpnsupport@example.com vpnsupportalias
vpssupport@example.com vpssupportalias

[root@wcloud ~]# grep -Ev ‘^#’ /etc/postfix/virtual
billing@example.com billingalias
sales@example.com salesalias
sharedsupport@example.com sharedsupportalias
support@example.com supportalias
vpnsupport@example.com vpnsupportalias
vpssupport@example.com vpssupportalias
[root@wcloud ~]#

Setup pipes based on the aliases defined above inside /etc/aliases
billingalias: “|/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
salesalias: “|/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
sharedsupportalias: “|/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
supportalias: “|/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
vpnsupportalias: “|/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
vpssupportalias: “|/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”

[root@wcloud ~]# grep -Ev ‘^#’ /etc/aliases | grep alias
billingalias: “|/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
salesalias: “|/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
sharedsupportalias: “|/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
supportalias: “|/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
vpnsupportalias: “|/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
vpssupportalias: “|/usr/bin/php -q /home/username/public_html/my.example.com/crons/pipe.php”
[root@wcloud ~]#

As root:
postmap /etc/postfix/virtual
systemctl restart postfix # or service postfix restart
newaliases

Also, +1 to this needs a proper gui support for those switching from cPanel > cyberpanel who are running osticket whmcs etc which uses email piping for support tickets. https://docs.whmcs.com/Email_Piping

I have tried this and I keep getting:

User unknown in virtual alias table. I have tried for days to get this piping to work… would REALLY love to see this as a feature for the GUI because this is a nightmare trying to do all this via command line and files not loading / working.

Any suggestions?

Can you provide the output of

grep -Ev ‘^#’ /etc/postfix/virtual
grep -Ev ‘^#’ /etc/aliases

Well after alot of learning python this feature has been pushed to github and should be available for use and testing once merged into base installer.

Special shoutout to @usmannasir for the GUI modding and help with some of the commands.

Screenshots

See the commits:

Enjoy

Basically all credits to @whattheserver

In case anyone comes across this I ended up updating the backend code in how this is done to use postfix filters to pipe vs /etc/aliases+/etc/postfix/virtual approach. The aliases method was having issues with the new dovecot and virtual users defaults.

The new method is more secure and works way better. If you have added any pipe to program forwarders just remove them update this one file. Alternatively you can wait and do the new cyberpanel update with this file in it and then readd them.

The new method is based on this:
http://www.zytrax.com/tech/survival/postfix.html#pipe

instead of /etc/aliases+/etc/postfix/virtual it uses /etc/postfix/script_filter + extra line added to /etc/postfix/master.cf
Format
sourceemail FILTER pipename:dummy
nano /etc/postfix/script_filter
test@example.com FILTER testpipe:dummy

Creates a pipe named sourcemail username+pipe like below
nano /etc/postfix/master.cf
testpipe unix - n n - - pipe flags=Rq user=linuxuserthatownspipedfile argv=/usr/bin/php -q /home/example.com/testpipe.php -f $(sender) – $(recipient)