电子邮件管道有效,但发送退回电子邮件

时间:2019-02-13 20:10:58

标签: php email pipe

我正在研究将电子邮件发送到数据库的脚本。 我的脚本可以运行,但是它也会发送退回电子邮件。

以下是退回邮件:

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

  pipe to |/home/montanah/public_html/admin/getmail.php
    generated by test@domain.com

The following text was generated during the delivery attempt:

------ pipe to |/home/montanah/public_html/admin/getmail.php
       generated by test@domain.com ------

这是我正在使用的代码:

#!/usr/bin/php -q
<?php
error_reporting(0);
require("db.php");
$email_msg = ''; // the content of the email that is being piped
// open a handle to the email
$fh = fopen("php://stdin", "r");
// read through the email until the end
while (!feof($fh)){
    $email_msg .= fread($fh, 1024);
}
fclose($fh); 
MDB::insert("res_recieved_mail", array("time"=>time(), "body"=>$email_msg, "status"=>1)); 
exit(0);

我尝试了以下所有方法: 以exit(0);结尾,而不以exit结尾。返回null ;,以?>结尾 我已修改0700、0755、0777 我确保在我的脚本或db.php中没有空行 我确保我的编辑器(notepad ++)使用的是UNIX新行而不是Windows,并且我以ASCII格式而不是二进制格式上传。

有什么想法吗?

0 个答案:

没有答案