• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Postfix Mail Aliases to forward to Command Pipe

S

szlampy

Guest
I am running Plesk 9.3.0 witht the postfix mail client on CentOS Linux.

I am trying to get a mail account to forward/redirect mail to script.

I don't really want to break the plesk control panels for managing the server.

The panels won't simply allow you to enter the pipe command (e.g. "|/usr/bin/perl /path/to/script") as an alias into the control panels as they have some email verification/normalization scripts running on the form input.

I am not 100% sure but from my investigations it appears that Parallels have configured Postfix to handle aliases from the MySQL DB called PSA via the mail, mail_aliases, mail_redir tables.

So I have set-up an aliases via the panels to forward the mail address I want handled by a script (scripted@domain.com) to forward to another address (mailbox@domain.com) and that all works as expected.

Then I logged into the DB and manually modified the entry in the DB so that the address being forwarded too (mailbox@domain.com) is changed to the pipe command to run the script ("|/usr/bin/perl /path/to/script").

Unfortunately mail being sent to scripted@domain.com is still being forwarded to mailbox@domain.com and NOT "|/usr/bin/perl /path/to/script" as expected.

I can therefore presume that this is happening because there's a script that updates the Postfix aliases from the DB once the data has been inputed, and manually editing the DB isn't triggering this script. That is why the old configuration is still being used.

The remedies as I see it now, are as follows:

a) Trigger the script that updates the Postfix aliases. (I've tried the obvious "postfix reload")
b) Disable/Change the verification on the plesk panels so that the script will now accept email addresses and scripts as valid entries for forwarding mail too.

SO... I'm after either the location/name of the script that updates the postfix aliases from plesk, or the location/name of the script that checks the input from the plesk panels. I partially suspect it may even be the same script.

Can anyone help me here?
 
Different Approach

We struggled for a while to a find a solution that work for this and was compatible with Plesk 9.2+ and failed.

Finally we opted for a completely different approach.

In the end we adopted a method using a perl script that is run as a cron job every minute. It simply checks the mailbox for new messages and processes them as we would have had the other script doing - it's not as 'instant' but it's a working solution.
 
plesk postfix pipe

Well, i've managed to make it work (i needed to make socketmail pipe work .. had qmail before)

Set up in plesk Mail accounts -> Mail settings -> Mail to nonexistent user -> Forward to address catchall@domain.com (create catchall@domain.com with mailbox).

In /etc/postfix/transport:

catchall@domain.com yourpipename:
----
(postmap /etc/postfix/transport)

In main.cf:
transport_maps = hash:/var/spool/postfix/plesk/transport, hash:/etc/postfix/transport
----

In master.cf:
yourpipename unix - n n - - pipe flags=O user=apache:apache argv=/usr/bin/php -c /etc/php-cli.ini -q /var/www/vhosts/domain.com/httpdocs/system-files/mx.php ${recipient}
----

(beware that ${recipient} will be catchall@domain.com, so i suggest you gather the To: field from X-Original-To: field which will be added by postfix-pipe due to the "O" flag.
In the documentation says you can use ${original_recipient} instead of ${recipient} but it works if you have postfix 2.5 or greater )

Now everytime a mail comes to catchall@domain.com it pipes to "yourpipename" in master.cf and does not store locally.

And it works like a charm!

Part of credits go to: http://www.hostnexus.com/forum/ples...ting-email-pipe-plesk-9-2-2-a.html#post110122

Cheers.
 
In main.cf:
transport_maps = hash:/var/spool/postfix/plesk/transport, hash:/etc/postfix/transport
----

In master.cf:
yourpipename unix - n n - - pipe flags=O user=apache:apache argv=/usr/bin/php -c /etc/php-cli.ini -q /var/www/vhosts/domain.com/httpdocs/system-files/mx.php ${recipient} actually does the deal :) it works.
 
Last edited by a moderator:
I am trying to get this work but I have this error in mailog:

Jun 21 13:55:28 lin5 postfix/pipe[27812]: C4DDF260846: to=<bounce@domain.com>, relay=pipeDomain, delay=0.24, delays=0.15/0.01/0/0.08, dsn=5.3.0, status=bounced (Command died with status 1: "/usr/bin/php". Command output: Could not open input file: /var/www/vhosts/domain.com/httpsdocs/front/piping/index.php )

Permissions
/var(755)/www(755)/vhosts(755)/domain.com(755)/httpsdocs(755)/front(755)/piping(755)/index.php(755)

/etc/postfix/master.cf
pipeDomain unix - n n - - pipe flags=O user=apache:apache argv=/usr/bin/php -c /etc/php-cli.ini -q /var/www/vhosts/domain.com/httpsdocs/front/piping/index.php ${recipient}

/etc/postfix/main.cf
transport_maps = hash:/var/spool/postfix/plesk/transport, hash:/etc/postfix/pipeDomain

/etc/postfix/pipeDomain
bounce@domain.com pipeDomain: description log Sent to pipeDomain

/etc/postfix/pipeDomain.db

In Mail settings -> Mail to nonexistent user -> Forward to address bounce@domain.com (created bounce@domain.com with mailbox).


I plave plesk 10.4.4

please help!!
 
I piped mail through Plesk using Postifix by:
Code:
vi /var/qmail/mailnames/domain.com/email_alias/.qmail
and in it you can add something like:
Code:
| /usr/bin/php /var/www/vhosts/domain.com/httpdocs/your_script_path/pipe.php
 
I think is a permission problem. If I put the php script in /etc/postfix/index.php

The pipe works

Jul 3 17:13:41 lin5 postfix/pipe[9769]: A91F4260814: to=<bounce@domain.com>, relay=pipe_s4_emsrv_es, delay=0.27, delays=0.17/0/0/0.1, dsn=2.0.0, status=sent (delivered via pipeDomain service)

but in /var/www/vhosts/domain.com/httpsdocs/front/piping/index.php dont:

Jul 3 17:45:42 lin5 postfix/pipe[10332]: 5591C2606F4: to=<bounce@domain.com>, relay=pipeDomain, delay=0.31, delays=0.18/0.01/0/0.12, dsn=5.3.0, status=bounced (Command died with status 1: "/usr/bin/php". Command output: Could not open input file: /var/www/vhosts/domain.com/httpsdocs/front/piping/index.php )
 
Back
Top