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!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP email piping formatting issue

Discussion in 'E-mail Discussions' 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:
    618
    Likes Received:
    192
    Trophy Points:
    43
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    42,802
    Likes Received:
    1,714
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    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.
     
Loading...

Share This Page