问题描述
我使用 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 (将#修改为@)