Google Answers Logo
View Question
 
Q: Piping in Postfix ( No Answer,   6 Comments )
Question  
Subject: Piping in Postfix
Category: Computers > Internet
Asked by: tarabyte7-ga
List Price: $2.00
Posted: 30 Aug 2005 23:49 PDT
Expires: 29 Sep 2005 23:49 PDT
Question ID: 562518
Hello,

I need to find out how to set up piping in Postfix.

More specifically, I want to send email to a virtual domain email
address, and then have it pipe the message into a PHP script for
parsing.  The message does not need to exist past the piping
procedure.

Right now it is so I can use Kayako's eSupport software, but also I
want to simply be able to parse some information from an email using
PHP and store it in Mysql (The parsing part is no problem; the piping
is where it is difficult)

thanks,
Tara
Answer  
There is no answer at this time.

Comments  
Subject: Re: Piping in Postfix
From: techtonix-ga on 31 Aug 2005 02:02 PDT
 
AFAIK you need to alter your master.cf configuration to include your
PHP script as a filter in postfix which serves your virtual domain
email. That is:

/etc/postfix/master.cf:
  # =============================================================
  # service type  private unpriv  chroot  wakeup  maxproc command
  #               (yes)   (yes)   (yes)   (never) (100)
  # =============================================================
  filter    unix  -       n       n       -        1      pipe
    flags=Rq user=filter argv=/path/to/script.php ${sender} ${recipient}

Make sure your script has #!/bin/php as first line and execution rights bit set.
For full list of options to pipe method see http://www.postfix.org/pipe.8.html
Subject: Re: Piping in Postfix
From: tarabyte7-ga on 31 Aug 2005 02:10 PDT
 
Thanks for the info...

How would I make it specific for just one virtual domain email address though?

~ Tara ~
Subject: Re: Piping in Postfix
From: techtonix-ga on 31 Aug 2005 06:16 PDT
 
You can try to:

1. In your /etc/postfix/main.cf add

smtpd_recipient_restrictions =
     permit_mynetworks,
     reject_unauth_destination,
     check_recipient_access hash:/etc/postfix/check_to
     
2. Create file /etc/postfix/check_to with the following content
forphpiping@domain.org     FILTER:filter

3. Note "FILTER:filter" in the file above - name "filter" denotes
string in your /etc/postfix/master.sf supplied in my previous post.


Should work ok - just change forphpiping@domain.org to your expected
address for piping. I suppose you've already read that page on how to
create the filter http://www.postfix.org/FILTER_README.html since the
parsing is not a problem for you. =)
Subject: Re: Piping in Postfix
From: tarabyte7-ga on 31 Aug 2005 13:40 PDT
 
I have tried this and it isn't working...

for virtual_mailbox_maps I'm using /etc/postfix/vmailbox
for virtual_alias_maps I'm using /etc/postfix/virtual

In my vmailbox, I have the following:
test@mynetmarketingsupport.com  /dev/null

In my master.cf, I have:
helpdesk  unix  -       n       n       -       1       pipe
  flags=Rq user=root argv=/web/helpdesk/cli/index.php ${sender} ${recipient}

In my check_to I have:
test@mynetmarketingsupport.com  FILTER:helpdesk

I of course added the entry you specified into the main.cf...

Here is the excerpt from my mail logs:
Aug 31 13:42:46 tarabyte postfix/smtpd[25099]: connect from
fed1rmmtao02.cox.net[68.230.241.37]
Aug 31 13:42:46 tarabyte postfix/smtpd[25099]: warning: SMTPD access
map hash:/etc/postfix/check_to has entry with lookup table:
FILTER:helpdesk
Aug 31 13:42:46 tarabyte postfix/smtpd[25099]: warning: do not specify
lookup tables inside SMTPD access maps
Aug 31 13:42:46 tarabyte postfix/smtpd[25099]: warning: define a
restriction class and specify its name instead.
Aug 31 13:42:46 tarabyte postfix/smtpd[25099]: NOQUEUE: reject: RCPT
from fed1rmmtao02.cox.net[68.230.241.37]: 451 Server configuration
error; from=<tara@livecreations.com>
to=<test@mynetmarketingsupport.com> proto=ESMTP
helo=<fed1rmmtao02.cox.net>

Any clue what is going on?

thanks,
Tara
Subject: Re: Piping in Postfix
From: techtonix-ga on 03 Sep 2005 01:32 PDT
 
Indeed, Postfix need to preload lookup table. BTW, which version do you use?
Add this to master.cf:

-----------
smtpd_restriction_classes =
   incoming_php_filter

incoming_php_filter =
   FILTER:helpdesk
-----------

and change /etc/postfix/check_to to
test@mynetmarketingsupport.com  incoming_php_filter
Subject: Re: Piping in Postfix
From: techtonix-ga on 03 Sep 2005 02:49 PDT
 
There seems to be another way to do the same thing without filters.
Define local adress in /etc/aliases to process email with your script
and redirect your virtual mail to it. The sequence is as follows:

1. /etc/aliases
yourtest: "|/web/helpdesk/cli/index.php"

2. /etc/postfix/virtual
test@mynetmarketingsupport.com  yourtest

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy