Piping mail to PHP scripts correctly - something wrong somewhere

webignition

Well-Known Member
Jan 22, 2005
1,876
0
166
I'd like to pipe mail addressed to [email protected] to a PHP script.

For the moment, the script does nothing other than send an email to me so that I can tell that it is being executed.

This seems to be working more or less correctly after a bit of confusion and changing the PHP script's permissions.

However something is not quite right as the sender receives a delivery failure message when sending to [email protected]

Here's what happens:

1. Sender sends email to [email protected]
2. Mail addressed to [email protected] is piped, using Cpanel email filters, to a PHP script.
3. I receive an email sent by the script, therefore indicating that the script is executing.
4. Sender receives a delivery failure message:

Code:
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 |/home/cos/mailhandlers/test.php
    generated by [email protected]
A mailbox exists for [email protected] and without the email filter in place emails sent to [email protected] are being delivered correctly. Delivery failure messages are only generated when the email filter is in place to pipe mail to a PHP script and the PHP script is being executed.

From reading previous delivery failure messages when things weren't working, I can see that the delivery failure message includes the output from the script (PHP errors). There is now nothing being output by the script.

The full script to which mail is piped is:

Code:
#!/usr/local/bin/php
<?php
	mail("[email protected]", "test message from mail handler", "msg");
?>
I have no idea why mail sent to [email protected] is generating delivery failure messages when the mail is being piped to the script correctly and the script is executing without any errors.

Any ideas what might be causing the delivery failures?
 

nitromax

Well-Known Member
Feb 12, 2002
189
0
316
Help!

Hey, can you provide a sample of the script you show in the post with the STDIN stuff in there?

I just want an email filter setup thru Cpanel so that when a certain pop3 account receives an email it sends a very simple email to my cell phone telling me I received an email to this account. That way I know to go and check my email on my computer.

Any help would be appreciated! Thanks in advance! :)