简体   繁体   English

电子邮件管道-工作正常,但电子邮件返回错误

[英]Email Piping - working but emails return errors

I have setup my email forwarding to "Pipe to a program". 我已将我的电子邮件转发设置为“管道到程序”。 The piping seems to be working because when an email is sent to my piped email address it returns an undelivered message with errors from my PHP script such as: 管道似乎正在工作,因为当电子邮件发送到我的管道电子邮件地址时,它会返回未送达的消息,其中包含来自我的PHP脚本的错误,例如:

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/badihbar/public_html/handEmlTst.php generated by badih@badihbarakat.com local delivery failed 由badih@badihbarakat.com生成的| /home/badihbar/public_html/handEmlTst.php本地传送失败

The following text was generated during the delivery attempt: 尝试交付期间生成了以下文本:

------ pipe to |/home/badihbar/public_html/handEmlTst.php generated by badih@badihbarakat.com ------ ------管道到| /home/badihbar/public_html/handEmlTst.php,由badih@badihbarakat.com生成------

/home/badihbar/public_html/handEmlTst.php: line 1: ?php: No such file or directory /home/badihbar/public_html/handEmlTst.php: line 3: //: is a directory /home/badihbar/public_html/handEmlTst.php: line 4: //: is a directory /home/badihbar/public_html/handEmlTst.php: line 5: syntax error near unexpected token (' /home/badihbar/public_html/handEmlTst.php: line 5: // date_default_timezone_set("Asia/Muscat");' /home/badihbar/public_html/handEmlTst.php:第1行:?php:没有此类文件或目录/home/badihbar/public_html/handEmlTst.php:第3行://:是目录/ home / badihbar / public_html / handEmlTst .php:第4行://:是目录/home/badihbar/public_html/handEmlTst.php:第5行:意外令牌附近的语法错误(' /home/badihbar/public_html/handEmlTst.php: line 5: // date_default_timezone_set (“亚洲/马斯喀特”);'

------ This is a copy of the message, including all the headers. ------这是消息的副本,包括所有标题。 ------ ------

Apparently, for some reason, it is not recognizing the php file to have php scripts. 显然,由于某种原因,它无法识别具有php脚本的php文件。 What I'm suspecting is the first line itself. 我怀疑的是第一行本身。 How can I know what path should i put after the "#!" 我怎么知道在“#!”之后应该走什么路? ?

My php script from handEmlTst.php: 我来自handEmlTst.php的php脚本:

#!/usr/lib/php -q
<?php

// include_once "Libraries/connection.class.php";
// include_once "includes/readini.inc.php";
// date_default_timezone_set("Asia/Muscat");

$starttime = date("h:i:s");

// create the connection object...
$s = ini_get("mysql.default_host");

$conn = mysql_connect($s,'badihbar_badih','letmein2013');

$db = "badihbar_supportcenter";

$attachments = array();

if(mysql_error())
{
    print "Error Occured: ".mysql_error()."<br>";
    $err = true;
}

mysql_select_db($db,$conn);

$commString  = "INSERT INTO scriptEmails (Message) VALUES ('From the Script - ".$starttime."')";

// , '".mysql_real_escape_string($email)."'

$result = mysql_query($commString, $conn);
if(mysql_error())
{
    // echo "Error Occured Saving Data: ".mysql_error()."<br>";
    // print $Conn->commString."<br>";
}


?>

I have checked phpinfo() for the path but honestly didn't know what I'm looking for. 我已经检查了phpinfo()的路径,但老实说不知道我在寻找什么。 So, I supposed that the php interpreter would be in usr/lib/ or something. 因此,我认为php解释器将位于usr / lib /之内。 Should I substitute usr with my domain user or something? 我应该用我的域用户代替usr吗? I appreciate if anybody can advise in this regard. 我很高兴有人可以就此提供建议。

many Thanks 非常感谢

I managed to get it working after all. 毕竟我设法使它工作。 Below are the steps for all to benefit... :) 以下是使所有人受益的步骤... :)

  1. I used phpinfo() to get the path for the php interpreter. 我使用phpinfo()获取php解释器的路径。 I used the "Configuration File (php.ini) Path" parameter value which was usr/lib/ for my server. 我为服务器使用了“配置文件(php.ini)路径”参数值usr / lib /。
  2. used #!/usr/lib/php -q as the first most line in my handling script. 使用#!/ usr / lib / php -q作为我的处理脚本中的第一行。
  3. This part was the issue in my case. 这部分是我的问题。 UPLOAD THE FILE AS ASCII, NOT BINARY! 以ASCII而非二进制格式上传文件!
  4. Made sure the chmod of the uploaded file was 755. 确保上载文件的chmod为755。
  5. Set the forwarding of my email address to "Pipe to a program" in my cpanel and put the path of the php script file I've uploaded. 将我的电子邮件地址的转发设置为cpanel中的“管道程序”,然后放置我已上传的php脚本文件的路径。

That's did it. 做到了。 As I mentioned, my problem was with the file being uploaded by the FTP application as binary instead of ASCII. 正如我提到的,我的问题是FTP应用程序将文件上传为二进制而不是ASCII。

Thanks, all... :) 谢谢,所有... :)

You can also use #!/usr/local/bin/php at the starting line on your PHP file, which is the cli binary instead of the cgi binary. 您还可以在PHP文件的起始行上使用#!/ usr / local / bin / php,它是cli二进制文件而不是cgi二进制文件。

This works for me, If you Passed above case as said by @Badih Barakat 如果您通过@Badih Barakat所说的以上情况,这对我有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM