Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Dreamhost, .procmailrc and PHP

Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
10-09-2005 13:12
Hi,

I'm seeing something weird when trying to send emails to a script. I can trigger a C program correctly through .procmailrc, it picks up the contents of the email from stdin (verified by copying stdin to a file). But I can't seem to trigger any PHP scripts. I've tried:

| /usr/local/bin/php -q /absolute/path/to/phpscript
| /absolute/path/to/phpscript
| /usr/local/bin/php -q /relative/path/to/phpscript
| /relative/path/to/phpscript

I've also tried calling a C program that invokes the php script using system() or execl(). No luck - anything to do with PHP doesn't work. This is with or without #!/usr/local/bin/php at the top of the script. If I invoke the scripts by hand, they work. If I use a C program to write the email to a file then invoke the PHP script by hand with input redirected from the file, it works. So I have my SL-server communication woring if I sit at my shell and manually invoke the script every time my SL script sends out an email.

What am I doing wrong? Is there a recipe to get this to work? All my scripts are under the Maildir, I thought maybe procmail wouldn't allow access outside that folder. The data files have 666 permissions on them, the binaries and scripts are 555. The folder they're in is 777 (I know, but I'm trying to get this to work). I suspect it's a permission thing, and maybe procmail invokes the scripts with a different environment/user/whatever , and that's breaking PHP for some reason.

Any help/advice would be appreciated.

Ziggy
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
10-10-2005 00:30
Well, I finally found something in the help files. It seems that procmail executes on the mail servers, and PHP isn't installed there, thus /usr/local/bin/php is non-existent. The solution was to build your own PHP and point .procmailrc to that. I tried that, following instructions I found. Now I get GLIBC_PRIVATE errors when I try to run php from .procmailrc, but it runs fine from the shell.

Has anyone tried compiling their own PHP on Dreamhost?
Kala Bijoux
Material Squirrel
Join date: 16 Nov 2004
Posts: 112
10-10-2005 23:42
Talking to myself here :)

How do people who use Dreamhost get emails to scripts? I can't use PHP because PHP isn't installed on the mail server where procmail runs, so it says /usr/local/bin/php not found. I can't use Python because even though python is installed, it's either an old version or something else is wrong, since it's not recognizing keywords in my scripts. It also didn't have all the libraries, but I solved that by copying/symlinking the ones on my server. So maybe Perl will work, assuming the mail server has everything needed to run Perl.

I also failed at compiling my own PHP, because of (I suspect) a glibc/ld.linux mismatch between the two servers. So something compiled on my server ends up using ld.linux.so on the mail server, which can't understand the libraries I built.

Either I'm missing something fundamental here, or this is pretty depressing :) Is everyone on DH piping their procmail to Perl scripts? Is anyone using anything other than Perl?
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
10-11-2005 00:51
I found a workaround, so I'll put it here in case someone else runs into this too. The solution is to send the mail to [email]user@xxx.dreamhost.com[/email], then the mail gets processed locally instead of on the mail server, and you can use a regular .forward (not postfix) to send all emails sent to that address to a script. And now the script will work, because it's running locally.

And now I'll stop talking to myself :)
Tai Tuppakaka
Curious Fellow
Join date: 13 Sep 2005
Posts: 109
10-11-2005 05:11
Thanks for the information. I will need to do this myself soon.