Piping to PHP via procmail


#1

Hello,

I turn to this board for support with my procmail rule… I am trying to do a simple procmail pipe to php. I have this exact rule setup locally on my Linux box and it works flawlessly… but I can’t get it to work on this Dreamhost server nor will any of the support techs help me… so I’m asking for help here…

Here is what the rule reads…

:0

  • ^subject:.(justin).
    | /usr/local/bin/php /home/favguys/mail.php >> /home/favguys/log.nt

the php file is basically a echo “OK”; and that gets outputted to the log.nt… But it refuses to work on this dreamhost box!

Any help would be appreciated. in my procmail log all it says is

From favguys@favguys.com Thu Nov 13 06:24:21 2003
Subject: justin
Folder: /usr/local/bin/php /home/favguys/mail.php >> /home/favguys/ 1728

Thanks Again


#2

Part of the reason for this is probably that /usr/local/bin/php doesn’t exist on most of the mail machines. I talked to the rest of our team and we should be installing that later (though I wouldn’t personally suggest using PHP to process mail).


#3

Just curious… why can I run

/usr/local/bin/php /home/favguys/mail.php >> /home/favguys/log.nt

from the same dir as the .procmailrc file? or is the mail server not the same server as my webserver? and if it isn’t… what difference would compiling my own php binary make? as it would be on the same server as /usr/local/bin/php… I only ask as this was one of the ‘things I might do’ from a support tech…

Thanks Will.

btw, what’s wrong with php proccessing mail ?


#4

[quote]or is the mail server not the same server as my webserver?

[/quote]

It’s not

[quote]if it isn’t… what difference would compiling my own php binary make?

[/quote]

Your home directory is mounted over NFS and exists on both the mail and the web machine. You can process mail through programs which exist in your home directory (though problems could come up if a program called other stuff that lived on the user machine but that wasn’t installed on the mail machine).

In general, we try to keep a fairly consistent environment in terms of perl modules, python version, etc., so that in most cases, processing stuff on the mail machines should work pretty much the same as doing it on the user machines.

[quote]btw, what’s wrong with php proccessing mail

[/quote]

Well I don’t know a lot about PHP, but it’s mostly designed for doing web application type stuff, no? Most people that process mail seem to use Perl or python. I definitely know people who have used PHP to do this sort of thing, so I imagine it will more or less work.


#5

[quote]Well I don’t know a lot about PHP, but it’s mostly designed for
doing web application type stuff, no? Most people that process mail
seem to use Perl or python. I definitely know people who have
used PHP to do this sort of thing, so I imagine it will more or less
work.

[/quote]

Having done both, I’d probably agree that Perl is the best way to go. Not because the “core” language is particularly better for this sort of thing (PHP has fairly robust regexp support, which is the main requirement), but because there is a large library of mail-oriented code in CPAN that you can use with Perl and not PHP. I for one found it much easier to find example code, etc. written for Perl, so that’s what I use for mail stuff.

If PHP were around for another 10 years - and had as big a following in sys-admin circles as it has in web development, there wouldn’t be a whole lot of difference really.

Choose your tools for their job, is my motto. Perl is great for shell stuff, sys-admin stuff, mail stuff - but it’s definitely not as quick or nice for developing web stuff. The beautiful thing is that there’s no harm in using both. :>

  • Jeff @ DreamHost
  • DH Discussion Forum Admin