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.

Email Pipe issues

Discussion in 'E-mail Discussions' started by fifebirder, Jan 11, 2016.

  1. fifebirder

    fifebirder Registered

    Joined:
    Jan 11, 2016
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    scotland
    cPanel Access Level:
    Website Owner
    Hi Guys

    New to this forum, i am relatively inexperienced at PHP but not a beginner or noob.

    I have set up in cpanel an email address and set up forwarding as such

    |/home/fifebirder/test.php

    i am using x3 style in my panel.

    Code:
    test.php file is :-
    
    #!/usr/bin/php -q
    <?php
    
    $fd = fopen( "php://stdin", "r" );
    
    $message = "";
    
    while ( !feof( $fd ) )
    {
      $message .= fread( $fd, 1024 );
    }
    
    fclose( $fd );
    
    // The $message variable now holds the entire message text,
    // which you can use for further processing.
    
    ?>
    
    
    as you can see i have my shebang in my basic script, i have only created a basic script as i know the rest of the script in my "real" forwarding script works fine.

    when i send an email to the email address that gets forwarded i keep getting this in my exim_mainlog file

    |/home/fifebirder/test.php (my@email.address) <my@email.address> R=virtual_aliases_nostar T=virtual_address_pipe: Child process of virtual_address_pipe transport returned 127 (could mean unable to exec or command does not exist) from command: /home/fifebirder/test.php

    my@email.address has been inserted instead of my real email address which i can send and recieve to.

    I have test.php set to 755 permission, have also tried setting it to 700.

    Can someone please help as i have now spend many hours reading online hints and tips and i am getting no where.

    Apologies if this is not the correct format to ask for help.
     
    #1 fifebirder, Jan 11, 2016
    Last edited by a moderator: Jan 12, 2016
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,450
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Your test.php script is posted around the Internet. Here's one site with some additional details you might find useful:
    a2hosting.com/kb/cpanel/cpanel-mail-features/forwarding-incoming-e-mail-messages-to-a-script-file
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    653
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    The output suggests you may have simply entered the path to the script. Instead, you have to enter it like this:

    Code:
    |php -q /home/user/public_html/path/script.php
    Thank you.
     
  4. fifebirder

    fifebirder Registered

    Joined:
    Jan 11, 2016
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    scotland
    cPanel Access Level:
    Website Owner
    cPanelMichael,

    x3 does not allow the pipe symbol.
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    653
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    I was noting the fact that it looks like you may have left out "php -q".

    Thank you.
     
  6. fifebirder

    fifebirder Registered

    Joined:
    Jan 11, 2016
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    scotland
    cPanel Access Level:
    Website Owner
    i have got it sort of working but form some reason
    [Removed - Please paste output in CODE tags]

    isnt getting the email, checking email logs says that it has been delivered, files have 1777 permissions
     
    #6 fifebirder, Jan 12, 2016
    Last edited by a moderator: Jan 12, 2016
  7. fifebirder

    fifebirder Registered

    Joined:
    Jan 11, 2016
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    scotland
    cPanel Access Level:
    Website Owner
    Code:
    PHP Warning:  fopen(MAIL.txt): failed to open stream: Permission denied in /home/fifebirder/public_html/Forum/specialscripts/test.php on line 11
    
    
    Warning: fopen(MAIL.txt): failed to open stream: Permission denied in /home/fifebirder/public_html/Forum/specialscripts/test.php on line 11 PHP Warning:  fwrite() expects parameter 1 to be resource, boolean given in /home/fifebirder/public_html/Forum/specialscripts/test.php on line 12
    
    
    Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/fifebirder/public_html/Forum/specialscripts/test.php on line 12 PHP Warning:  fclose() expects parameter 1 to be resource, boolean given in /home/fifebirder/public_html/Forum/specialscripts/test.php on line 13
    
    
    Warning: fclose() expects parameter 1 to be resource, boolean given in /home/fifebirder/public_html/Forum/specialscripts/test.php on line 13
    
     
    #7 fifebirder, Jan 12, 2016
    Last edited by a moderator: Jan 12, 2016
  8. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,450
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    You might do better to find the author of the script, or a coding forum for support with this. The problem is with your script, not your cPanel.
     
Loading...

Share This Page