I'm trying to forward my site's incoming mail to a PHP script for it to be filtered an remailed to other addresses according to their content.

I've created a .forward file in my home directory and put in the following code:

myemail@yahoo.com,"|/public_html/myfolder/incl_mail.php"

Also, in the incl_mail.php file I've put this in the first line:

#!/usr/bin/php
<?php

Rest of the code

?>

All the emails that I send to my site are correctly sent to the email address but never get to the php script. I get a mail back saying that my message was undeliverable:

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

pipe to |/public_html/myfolder/incl_mail.php
generated by mysite@gator4.hostgator.com
(ultimately generated from test@mysite.com)

Does anybody know what I'm doing wrong? Am I putting in the path incorrectly (not full path)? Might it be my hosting company? I'd appreciate some help.

Thanks!

    i cant tell you for sure but i think you are putting the path wrong. i would imagine its more like /home/user/public_html... but you will have to check to make sure. you should be able to just create a php file and in it put <?php echo $_SERVER["DOCUMENT_ROOT"]; ?> and it will tell you the full path to your home directory.
    if you havnt already seen it, have a look here:
    http://evolt.org/article/Incoming_Mail_and_PHP/18/27914/index.html

      Write a Reply...