PHPList(2.10.17版)未能將消息發送到符合以下格式之一的是地址的電子郵件地址:PHPList失敗用於與前置,或多個相鄰點
[email protected]
[email protected]
[email protected]
該錯誤消息是Could not instantiate mail function.
有問題的代碼是:
function MailSend($header, $body) {
$to = "";
for($i = 0; $i < count($this->to); $i++)
{
if($i != 0) { $to .= ", "; }
$to .= $this->to[$i][0];
}
if ($this->Sender != "" && (bool) ini_get("safe_mode") === FALSE)
{
$old_from = ini_get("sendmail_from");
ini_set("sendmail_from", $this->Sender);
$params = sprintf("-oi -f %s", $this->Sender);
$rt = @mail($to, $this->EncodeHeader($this->Subject), $body,
$header, $params);
}
else
$rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header);
if (isset($old_from))
ini_set("sendmail_from", $old_from);
if(!$rt)
{
$this->SetError($this->Lang("instantiate"));
return false;
}
return true;
}
所選擇的代碼路徑是:
else
$rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header);
我無法在自己的web服務器上重現此錯誤,我在其中爲測試目的設置了PHPList。
不幸的是,唯一顯示此行爲的系統是生產系統。補充一點,我沒有訪問該系統上的任何日誌文件 - 所以我不知道什麼是錯的。
我最好的猜測是,$to
需要某種「字符串轉義」來完成這項工作,但我有點不情願篡改生產系統(除了插入一些日誌輸出)。
有沒有人知道這種問題的解決方法?
你正在壓制錯誤,你爲什麼要這樣做?每當你的代碼運行上帝殺死一隻小貓。我希望你爲自己感到自豪。 – 2012-02-06 20:34:19
@truth大聲笑。你對壓制錯誤是正確的。不要那樣做。 – ThinkingMonkey 2012-02-06 20:35:45
@Truth err ...我不是。問問PHPList的人爲什麼這麼做......我確信他們有很多原因。原因可能是,腳本是通過cron作業執行的。 – yas4891 2012-02-06 20:36:50