{"id":59,"date":"2023-10-06T08:39:39","date_gmt":"2023-10-06T08:39:39","guid":{"rendered":"https:\/\/new.hostitsmart.com\/manage\/knowledgebase\/?p=59"},"modified":"2024-09-20T07:34:19","modified_gmt":"2024-09-20T07:34:19","slug":"how-to-pipe-an-email-to-a-php","status":"publish","type":"post","link":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/59\/how-to-pipe-an-email-to-a-php.html","title":{"rendered":"How to pipe an email to a PHP"},"content":{"rendered":"\n<p>In some cases you might need to redirect a given mailbox to a PHP script to handle the incoming messages. This can be easily done with&nbsp;<strong>cPanel -&gt; Forwarders<\/strong>&nbsp;tool.<\/p>\n\n\n\n<p>To set up pipe forwarding, you can follow the steps below:<\/p>\n\n\n\n<p>\u2013 Log in to your cPanel;<\/p>\n\n\n\n<p>\u2013 Click on the&nbsp;<strong>Forwarders<\/strong>&nbsp;icon, under the Mail section;<\/p>\n\n\n\n<p>\u2013 Click on the&nbsp;<strong>Add Forwarder<\/strong>&nbsp;button;<\/p>\n\n\n\n<p>\u2013 Fill in&nbsp;<strong>Address to Forward<\/strong>&nbsp;and put the mail address you would like to pipe the messages from.<\/p>\n\n\n\n<p>\u2013 Click on the&nbsp;<strong>Advanced options<\/strong>&nbsp;link and select&nbsp;<strong>Pipe to a Program<\/strong>. Then fill in the full path to the script which will handle the messages. Bear in mind that the path is relative to your home directory, so if you create a script\/file called&nbsp;<strong>pipescript.php<\/strong>&nbsp;placed inside your home\/ folder you should fill in only&nbsp;<strong>pipescript.php<\/strong>&nbsp;inside the&nbsp;<strong>Pipe to a Program<\/strong>&nbsp;field. If the script is situated inside the&nbsp;<em>public_html\/<\/em>&nbsp;folder you should fill in&nbsp;<strong>public_html\/pipescript.php<\/strong><\/p>\n\n\n\n<p>There are several important things you should check regarding the PHP script which is handling the email messages:<\/p>\n\n\n\n<p>\u2013 Ensure the very first line of the script is a hashbang (also called shebang). This is a special line which identifies the file as a PHP script. In most cases it should look like this:<\/p>\n\n\n\n<p><em>#!\/usr\/bin\/php -q<\/em><\/p>\n\n\n\n<p>\u2013 Make sure that there are no whitespaces or blank lines before the above line as this will be sent to the mail server, which will result in a bounced message. The&nbsp;<strong>\u2013q<\/strong>&nbsp;option instructs PHP not to print its version either, since this will also result in a bounced message.<\/p>\n\n\n\n<p>\u2013 Make sure that the script permissions are set correctly. In most cases, you would simply need to <a href=\"https:\/\/www.siteground.com\/kb\/manage-files-file-manager\/\">change the permissions<\/a>, either via your cPanel -&gt; File Manager or through an FTP client and set them to&nbsp;<strong>755<\/strong>. This will make the script executable.<\/p>\n\n\n\n<p>Below you can find a sample PHP script which handles piped messages. The script will read the input from the STDIN and then save the full message into a file called&nbsp;<strong>pipemail.txt<\/strong>&nbsp;(make sure you provide the full path to the pipemail.txt file).<\/p>\n\n\n<table class=\"crayon-table\" style=\"border-collapse: collapse !important; font-size: 12px; border: none !important; padding: 0px !important; font-family: Monaco, MonacoRegular, 'Courier New', monospace; width: auto !important; border-spacing: 0px !important; color: #666666; font-style: normal; font-variant: normal; font-weight: 500; letter-spacing: normal; line-height: 15px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-image: none !important; background-attachment: initial !important; background-color: #fdfdfd; background-size: initial !important; background-origin: initial !important; background-clip: initial !important; background-position: initial !important; background-repeat: initial !important; margin: 0px !important 0px !important 0px !important 0px;\">\n<tbody style=\"font-family: Monaco, MonacoRegular, 'Courier New', monospace !important;\">\n<tr class=\"crayon-row\" style=\"font-family: Monaco, MonacoRegular, 'Courier New', monospace !important; padding: 0px !important; border: none !important; vertical-align: top !important; margin: 0px !important; background: 0px 50%;\">\n<td class=\"crayon-nums\" style=\"margin: 0px !important; padding: 0px !important; font-family: Monaco, MonacoRegular, 'Courier New', monospace !important; vertical-align: top !important; border: 0px; color: #d4d4d4 !important; background: #fdfdfd !important;\" data-settings=\"show\">\n<div class=\"crayon-nums-content\" style=\"font-family: Monaco, MonacoRegular, 'Courier New', monospace !important; border: 0px; padding: 0px; margin: 0px; text-align: left; white-space: nowrap; font-size: 12px !important; line-height: 15px !important; background: 0px 50%;\">\n<div class=\"crayon-num\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: 0px 50%;\" data-line=\"crayon-540ee61689a1b700813511-1\">1<\/div>\n<div class=\"crayon-num crayon-striped-num\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #d4d4d4 !important; background: #fafafa !important;\" data-line=\"crayon-540ee61689a1b700813511-2\">2<\/div>\n<div class=\"crayon-num\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: 0px 50%;\" data-line=\"crayon-540ee61689a1b700813511-3\">3<\/div>\n<div class=\"crayon-num crayon-striped-num\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #d4d4d4 !important; background: #fafafa !important;\" data-line=\"crayon-540ee61689a1b700813511-4\">4<\/div>\n<div class=\"crayon-num\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: 0px 50%;\" data-line=\"crayon-540ee61689a1b700813511-5\">5<\/div>\n<div class=\"crayon-num crayon-striped-num\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #d4d4d4 !important; background: #fafafa !important;\" data-line=\"crayon-540ee61689a1b700813511-6\">6<\/div>\n<div class=\"crayon-num\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: 0px 50%;\" data-line=\"crayon-540ee61689a1b700813511-7\">7<\/div>\n<div class=\"crayon-num crayon-striped-num\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #d4d4d4 !important; background: #fafafa !important;\" data-line=\"crayon-540ee61689a1b700813511-8\">8<\/div>\n<div class=\"crayon-num\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: 0px 50%;\" data-line=\"crayon-540ee61689a1b700813511-9\">9<\/div>\n<div class=\"crayon-num crayon-striped-num\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #d4d4d4 !important; background: #fafafa !important;\" data-line=\"crayon-540ee61689a1b700813511-10\">10<\/div>\n<div class=\"crayon-num\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: 0px 50%;\" data-line=\"crayon-540ee61689a1b700813511-11\">11<\/div>\n<div class=\"crayon-num crayon-striped-num\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #d4d4d4 !important; background: #fafafa !important;\" data-line=\"crayon-540ee61689a1b700813511-12\">12<\/div>\n<div class=\"crayon-num\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: 0px 50%;\" data-line=\"crayon-540ee61689a1b700813511-13\">13<\/div>\n<div class=\"crayon-num crayon-striped-num\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #d4d4d4 !important; background: #fafafa !important;\" data-line=\"crayon-540ee61689a1b700813511-14\">14<\/div>\n<div class=\"crayon-num\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: 0px 50%;\" data-line=\"crayon-540ee61689a1b700813511-15\">15<\/div>\n<\/div>\n<\/td>\n<td class=\"crayon-code\" style=\"margin: 0px !important; padding: 0px !important; font-family: Monaco, MonacoRegular, 'Courier New', monospace !important; vertical-align: top !important; border: 0px; width: 510px; background: 0px 50%;\">\n<div class=\"crayon-pre\" style=\"font-family: Monaco, MonacoRegular, 'Courier New', monospace !important; border: none !important; padding: 0px; margin: 0px; text-align: left; color: #000000; white-space: pre; overflow: visible; font-size: 12px !important; line-height: 15px !important; background: none !important;\">\n<div id=\"crayon-540ee61689a1b700813511-1\" class=\"crayon-line\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: 0px 50%;\"><span class=\"crayon-c\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #888888 !important;\">#!\/usr\/bin\/php -q<\/span><\/div>\n<div id=\"crayon-540ee61689a1b700813511-2\" class=\"crayon-line crayon-striped-line\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: #fafafa !important;\"><span class=\"crayon-ta\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #e91e1e !important;\">&lt;?<\/span><\/div>\n<div id=\"crayon-540ee61689a1b700813511-3\" class=\"crayon-line\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: 0px 50%;\"><span class=\"crayon-c\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #888888 !important;\">\/* Read the message from STDIN *\/<\/span><\/div>\n<div id=\"crayon-540ee61689a1b700813511-4\" class=\"crayon-line crayon-striped-line\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: #fafafa !important;\"><span class=\"crayon-v\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #222222 !important;\">$fd<\/span><span class=\"crayon-o\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #222222 !important;\">=<\/span><span class=\"crayon-e\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #cc6600 !important;\">fopen<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">(<\/span><span class=\"crayon-s\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #006699 !important;\">&#8220;php:\/\/stdin&#8221;<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">,<\/span><span class=\"crayon-s\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #006699 !important;\">&#8220;r&#8221;<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">)<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">;<\/span><\/div>\n<div id=\"crayon-540ee61689a1b700813511-5\" class=\"crayon-line\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: 0px 50%;\"><span class=\"crayon-v\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #222222 !important;\">$email<\/span><span class=\"crayon-o\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #222222 !important;\">=<\/span><span class=\"crayon-s\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #006699 !important;\">&#8220;&#8221;<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">;<\/span><span class=\"crayon-c\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #888888 !important;\">\/\/ This will be the variable holding the data.<\/span><\/div>\n<div id=\"crayon-540ee61689a1b700813511-6\" class=\"crayon-line crayon-striped-line\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: #fafafa !important;\"><span class=\"crayon-st\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: bold !important; color: #cc6600 !important;\">while<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">(<\/span><span class=\"crayon-o\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #222222 !important;\">!<\/span><span class=\"crayon-e\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #cc6600 !important;\">feof<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">(<\/span><span class=\"crayon-v\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #222222 !important;\">$fd<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">)<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">)<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">{<\/span><\/div>\n<div id=\"crayon-540ee61689a1b700813511-7\" class=\"crayon-line\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: 0px 50%;\"><span class=\"crayon-v\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #222222 !important;\">$email<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">.<\/span><span class=\"crayon-o\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #222222 !important;\">=<\/span><span class=\"crayon-e\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #cc6600 !important;\">fread<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">(<\/span><span class=\"crayon-v\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #222222 !important;\">$fd<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">,<\/span><span class=\"crayon-cn\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #222222 !important;\">1024<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">)<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">;<\/span><\/div>\n<div id=\"crayon-540ee61689a1b700813511-8\" class=\"crayon-line crayon-striped-line\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: #fafafa !important;\"><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">}<\/span><\/div>\n<div id=\"crayon-540ee61689a1b700813511-9\" class=\"crayon-line\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: 0px 50%;\"><span class=\"crayon-e\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #cc6600 !important;\">fclose<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">(<\/span><span class=\"crayon-v\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #222222 !important;\">$fd<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">)<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">;<\/span><\/div>\n<div id=\"crayon-540ee61689a1b700813511-10\" class=\"crayon-line crayon-striped-line\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: #fafafa !important;\"><span class=\"crayon-c\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #888888 !important;\">\/* Saves the data into a file *\/<\/span><\/div>\n<div id=\"crayon-540ee61689a1b700813511-11\" class=\"crayon-line\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: 0px 50%;\"><span class=\"crayon-v\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #222222 !important;\">$fdw<\/span><span class=\"crayon-o\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #222222 !important;\">=<\/span><span class=\"crayon-e\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #cc6600 !important;\">fopen<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">(<\/span><span class=\"crayon-s\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #006699 !important;\">&#8220;\/home\/user\/pipemail.txt&#8221;<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">,<\/span><span class=\"crayon-s\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #006699 !important;\">&#8220;w+&#8221;<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">)<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">;<\/span><\/div>\n<div id=\"crayon-540ee61689a1b700813511-12\" class=\"crayon-line crayon-striped-line\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: #fafafa !important;\"><span class=\"crayon-e\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #cc6600 !important;\">fwrite<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">(<\/span><span class=\"crayon-v\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #222222 !important;\">$fdw<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">,<\/span><span class=\"crayon-v\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #222222 !important;\">$email<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">)<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">;<\/span><\/div>\n<div id=\"crayon-540ee61689a1b700813511-13\" class=\"crayon-line\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: 0px 50%;\"><span class=\"crayon-e\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #cc6600 !important;\">fclose<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">(<\/span><span class=\"crayon-v\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #222222 !important;\">$fdw<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">)<\/span><span class=\"crayon-sy\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #333333 !important;\">;<\/span><\/div>\n<div id=\"crayon-540ee61689a1b700813511-14\" class=\"crayon-line crayon-striped-line\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: #fafafa !important;\"><span class=\"crayon-c\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #888888 !important;\">\/* Script End *\/<\/span><\/div>\n<div id=\"crayon-540ee61689a1b700813511-15\" class=\"crayon-line\" style=\"font-family: inherit; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; background: 0px 50%;\"><span class=\"crayon-ta\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #e91e1e !important;\"><span class=\"crayon-ta\" style=\"font-family: inherit; height: inherit; font-size: inherit !important; line-height: inherit !important; font-weight: inherit !important; color: #e91e1e !important;\">?&gt;<\/span><\/span>\n<p><span>where the user from the<span class=\"Apple-converted-space\">\u00a0<\/span><\/span><\/p>\n<p><span><em style=\"color: #666666; font-family: Arial, Tahoma, Verdana, sans-serif; font-size: 12px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;\">\/home\/user\/pipemail.txt<\/em><span style=\"font-family: Arial,Tahoma,Verdana,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; display: inline ! important; float: none; background-color: #ffffff;\"><span class=\"Apple-converted-space\">\u00a0<\/span>line is your cPanel username.<\/span><\/span><\/p>\n<\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>","protected":false},"excerpt":{"rendered":"<p>In some cases you might need to redirect a given mailbox to a PHP script to handle the incoming messages. This can be easily done with&nbsp;cPanel -&gt; Forwarders&nbsp;tool. To set up pipe forwarding, you can follow the steps below: \u2013 Log in to your cPanel; \u2013 Click on the&nbsp;Forwarders&nbsp;icon, under the Mail section; \u2013 Click [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-59","post","type-post","status-publish","format-standard","hentry","category-e-mail"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to pipe an email to a PHP<\/title>\n<meta name=\"description\" content=\"This tutorial will help you to pipe an email to a PHP script. It shows you the complete setup of an email pipe on your server.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/59\/how-to-pipe-an-email-to-a-php.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to pipe an email to a PHP\" \/>\n<meta property=\"og:description\" content=\"This tutorial will help you to pipe an email to a PHP script. It shows you the complete setup of an email pipe on your server.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/59\/how-to-pipe-an-email-to-a-php.html\" \/>\n<meta property=\"og:site_name\" content=\"Host IT Smart Knowledge base\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-06T08:39:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-20T07:34:19+00:00\" \/>\n<meta name=\"author\" content=\"Admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/59\/how-to-pipe-an-email-to-a-php.html\",\"url\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/59\/how-to-pipe-an-email-to-a-php.html\",\"name\":\"How to pipe an email to a PHP\",\"isPartOf\":{\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#website\"},\"datePublished\":\"2023-10-06T08:39:39+00:00\",\"dateModified\":\"2024-09-20T07:34:19+00:00\",\"author\":{\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/317c14a877385667f19d3b7496bd5108\"},\"description\":\"This tutorial will help you to pipe an email to a PHP script. It shows you the complete setup of an email pipe on your server.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/59\/how-to-pipe-an-email-to-a-php.html\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#website\",\"url\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/\",\"name\":\"Host IT Smart Knowledge base\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/317c14a877385667f19d3b7496bd5108\",\"name\":\"Admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d4827c56a6721070dde339640d47ff44ba0d0e515c7e577cf29305ab72383fe3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d4827c56a6721070dde339640d47ff44ba0d0e515c7e577cf29305ab72383fe3?s=96&d=mm&r=g\",\"caption\":\"Admin\"},\"sameAs\":[\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/\"],\"url\":\"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to pipe an email to a PHP","description":"This tutorial will help you to pipe an email to a PHP script. It shows you the complete setup of an email pipe on your server.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/59\/how-to-pipe-an-email-to-a-php.html","og_locale":"en_US","og_type":"article","og_title":"How to pipe an email to a PHP","og_description":"This tutorial will help you to pipe an email to a PHP script. It shows you the complete setup of an email pipe on your server.","og_url":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/59\/how-to-pipe-an-email-to-a-php.html","og_site_name":"Host IT Smart Knowledge base","article_published_time":"2023-10-06T08:39:39+00:00","article_modified_time":"2024-09-20T07:34:19+00:00","author":"Admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Admin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/59\/how-to-pipe-an-email-to-a-php.html","url":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/59\/how-to-pipe-an-email-to-a-php.html","name":"How to pipe an email to a PHP","isPartOf":{"@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#website"},"datePublished":"2023-10-06T08:39:39+00:00","dateModified":"2024-09-20T07:34:19+00:00","author":{"@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/317c14a877385667f19d3b7496bd5108"},"description":"This tutorial will help you to pipe an email to a PHP script. It shows you the complete setup of an email pipe on your server.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/59\/how-to-pipe-an-email-to-a-php.html"]}]},{"@type":"WebSite","@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#website","url":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/","name":"Host IT Smart Knowledge base","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/317c14a877385667f19d3b7496bd5108","name":"Admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d4827c56a6721070dde339640d47ff44ba0d0e515c7e577cf29305ab72383fe3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d4827c56a6721070dde339640d47ff44ba0d0e515c7e577cf29305ab72383fe3?s=96&d=mm&r=g","caption":"Admin"},"sameAs":["https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/"],"url":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/posts\/59","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/comments?post=59"}],"version-history":[{"count":7,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/posts\/59\/revisions"}],"predecessor-version":[{"id":1832,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/posts\/59\/revisions\/1832"}],"wp:attachment":[{"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/media?parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/categories?post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostitsmart.com\/manage\/knowledgebase\/wp-json\/wp\/v2\/tags?post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}