微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 php Cpanel 中管道恢复电子邮件

如何解决在 php Cpanel 中管道恢复电子邮件

我使用 o2switch 的 CPANEL,访问权限相当有限,例如我无法安装 pear。

我想制作一个电子邮件管道,以便在 PHP 脚本上重定向电子邮件,我只想获取正文而不是所有随附的便便,而且文档很少... Screen here

     #!/usr/local/bin/PHP -c  /home/-/public_html/PHP.ini -q
<?PHP
// source : https://forums.cpanel.net/f5/email-forward-PHP-script-39083.html
// read from stdin
 $fd = fopen("PHP://stdin","r");
 $email = "";
 while (!feof($fd)) {
$email .= fread($fd,1024);
 }
   fclose($fd);

   // handle email
   $lines = explode("\n",$email);

  // empty vars
   $from = "";
    $subject = "";
    $headers = "";
    $message = "";
    $splittingheaders = true;

    for ($i=0; $i < count($lines); $i++) {
    if ($splittingheaders) {
    // this is a header
    $headers .= $lines[$i]."\n";

    // look out for special headers
    if (preg_match("/^Subject: (.*)/",$lines[$i],$matches)) {
        $subject = $matches[1];
    }
    if (preg_match("/^From: (.*)/",$matches)) {
        $from = $matches[1];
    }
} else {
    // not a header,but message
    $message .= $lines[$i]."\n";
}

if (trim($lines[$i])=="") {
    // empty line,header section has ended
    $splittingheaders = false;
   }
   }

 file_put_contents('/home/-/public_html/mail.txt',$message,LOCK_EX);

 $to = $from;
$sb = "PIPING";
$body = "$from - $subject - $message";
$headers = "From: x@mal.lu\r\n";
$headers .= "Reply-To: REPLYTOADDRESS\r\n";
$headers .= "Return-Path: RETURNPATHADDRESS\r\n";
mail($to,$sb,$body,$headers);

exit(0);
 
?>

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。