Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

PHP email piping formatting issue

Discussion in 'E-mail Discussion' started by mrjasonh98, Dec 25, 2017.

  1. mrjasonh98

    mrjasonh98 Registered

    Joined:
    Jul 20, 2017
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Australia
    cPanel Access Level:
    Website Owner
    I've set up an email forwarder in cPanel which pipes any incoming email to pipe.php. The email then gets forwarded to a different email (myself@example.com for example) via pipe.php. In the future, I'll have DB calls determining where the email should be forwarded to, based on the sender etc...

    But at the moment I'm just trying to set up the forwarder properly.

    PHP:
    #!/usr/bin/php -q

    <?php

    $fd 
    fopen"php://stdin""r" );

    $message "";

    while ( !
    feof$fd ) )
    {
       
    $message .= fread$fd1024 );
    }

    fclose$fd );

    mail('myself@example.com','New message!',$message)

    ?>
    The email forwards to me just fine, however I'm experiencing two issues I'm hoping someone could help me out with:

    1. The $message appears in plain text with all of the MIME stuff - so the email just looks like jibberish to the average user.
    2. Although the email gets forwarded just fine, the sender gets an email saying that it has bounced (even though the script has worked perfectly)
    I'm new to this PHP email forwarding with cPanel - so all help would be appreciated!

    I'd like to keep this pipe as lean as possible.
     
  2. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    911
    Likes Received:
    351
    Trophy Points:
    113
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,216
    Likes Received:
    1,937
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    You'd want to use a resource such as the link in the previous post or a website such as StackOverflow for help with the PHP coding itself to ensure the message format is as you intend. As far as the bounce message, what do you see in /var/log/exim_mainlog when that happens?

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice