The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Piping mail to PHP scripts correctly - something wrong somewhere

Discussion in 'E-mail Discussions' started by webignition, Feb 5, 2005.

  1. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    I'd like to pipe mail addressed to support@domain 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 support@domain.

    Here's what happens:

    1. Sender sends email to support@domain.
    2. Mail addressed to support@domain 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 support@domain
    A mailbox exists for support@domain and without the email filter in place emails sent to support@domain 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("me@domain", "test message from mail handler", "msg");
    ?>
    I have no idea why mail sent to support@domain 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?
     
  2. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    A thought . . .

    Would the PHP script to which mail is being piped have to read in the message from STDIN for Exim to recognise the mail as having been delivered?
     
  3. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    Well, reading in the message through STDIN seems to stop the delivery failures.

    Maybe this information will prove to be of some use to someone else!
     
  4. nitromax

    nitromax Well-Known Member

    Joined:
    Feb 12, 2002
    Messages:
    189
    Likes Received:
    0
    Trophy Points:
    16
    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! :)
     
Loading...

Share This Page