2 Procmail Issues


#1

Hello,

I read this article on how to setup procmail and everything seams ok
from a setup stand point (So I think)
https://panel.dreamhost.com/kbase/index.cgi?area=2626

Ok so so I have 2 problems here.

#1 I can’t get procmail to execute a shell or php script. I just get an error in the log.
This is the error I get in the log when it does not work:
procmail: Executing "php,/home/mydir/php_exec_test.php"
php: php: No such file or directory

or this when I try a shell script
procmail: Unable to treat as directory
"/home/mydir/php_exec_test.sh"
procmail: Skipped “/home/mydir/php_exec_test.sh”

This is what is in my filter .rc file: (Note I have tired putting the “|” pipe before the command as well in all the below examples)

This works! (This works. Just moves the mail to a folder called “test”)
:0

  • ^Subject:.*test666
    .test/

When I try this it does not work
:0

  • ^Subject:.*test666
    /usr/local/bin/php -f /home/mydir/php_exec_test.php

Or this
:0

  • ^Subject:.*test666
    php -f /home/mydir/php_exec_test.php

Or this
:0

  • ^Subject:.*test666
    php -g /home/mydir/php_exec_test.php

Or this
:0

  • ^Subject:.*test666
    /home/mydir/php_exec_test.php

Or even calling a shell script that calls the php script
:0

  • ^Subject:.*test666
    /home/mydir/php_exec_test.sh

#2 I want to process a differnt mailbox and can’t seam to find out how
to
do that.
I have tried this for my “.forward.postfix” file
"|IFS=’ ’ && exec /usr/bin/procmail -t || exit 75 #OTHER_MAIL_BOX_HERE"

The main system mailbox is processed but my other is ignored.

I bet both of these are a very simple things and I am missing something.


#2
  • ^Subject:.*test666
    /usr/local/bin/php -f /home/mydir/php_exec_test.php

[/quote]

There has to be a pipeline first (and you may need to quote the whole string…

Probably something like (untested):
:0

  • ^Subject:.*test666
    |/usr/local/bin/php -f /home/mydir/php_exec_test.php

quote#2 I want to process a differnt mailbox and can’t seam to find
out how to do that.

[/quote]

You can’t.


#3

Ok I tried it with the pipe and quotes.

:0

  • ^Subject:.*test666
    |"/usr/local/bin/php -f /home/mydir/php_exec_test.php"

This is what I get in the error log.

— Logging /home/mydir/procmail.log for ccmcweb, procmail: [1180] Fri Mar 7 22:16:02 2003
procmail: Assigning "SHELL=/bin/sh"
procmail: Assigning "INCLUDERC=/home/mydir/filters.rc"
procmail: Match on "^Subject:.*test666"
procmail: Executing "/usr/local/bin/php -f /home/mydir/php_exec_test.php"
procmail: Assigning "LASTFOLDER=/usr/local/bin/php -f /home/mydir/php_exec_test.php"
procmail: Notified comsat: "xxxxxxx@:/usr/local/bin/php -f /home/mydir/php_exec_test.php"
From xxxxxxx@yahoo.com Fri Mar 7 22:16:02 2003
Subject: test666
Folder: /usr/local/bin/php -f /home/mydir/php_exec_t 1313
/usr/local/bin/php -f /home/mydir/php_exec_test.php: /usr/local/bin/php -f /home/mydir/php_exec_test.php: No such file or directory

This is what the filter looks like without the quotes.
:0

  • ^Subject:.*test666
    |/usr/local/bin/php -f /home/mydir/php_exec_test.php

And here is the log for it. Note the ‘,’ commas on the below before and after the I call php

— Logging /home/mydir/procmail.log for ccmcweb, procmail: [2361] Fri Mar 7 22:19:06 2003
procmail: Assigning "SHELL=/bin/sh"
procmail: Assigning "INCLUDERC=/home/mydir/filters.rc"
procmail: Match on "^Subject:.*test666"
procmail: Assigning "LASTFOLDER=/usr/local/bin/php -f /home/mydir/php_exec_test.php"
procmail: Executing "/usr/local/bin/php,-f,/home/mydir/php_exec_test.php"
procmail: Notified comsat: "xxxxxxx@:/usr/local/bin/php -f /home/mydir/php_exec_test.php"
From xxxxxx@yahoo.com Fri Mar 7 22:19:06 2003
Subject: test666
Folder: /usr/local/bin/php -f /home/mydir/php_exec_t 1310
/usr/local/bin/php: /usr/local/bin/php: No such file or directory

Oh thanks for the answer on #2


#4

[quote]/usr/local/bin/php -f /home/mydir/php_exec_test.php: /usr/local/bin/php -f /home/mydir/php_exec_test.php: No such file or directory

[/quote]

PHP isn’t installed on the mail machines. You could either install your own version of PHP (in your home directory), copy the PHP binary to ~/bin/ (and reference that), or write the script in Perl. I could probably install PHP on the mail machines with no problem, but I wouldn’t want you to run into problems further down the road if something changes. I think most people would probably use Perl or Python for this task.


#5

Ohhhhhhhhhhh. Thanks for the answers. Sorry I did not know that.