嘗試發送電子郵件時出現以下代碼錯誤。它適用於我的本地機器,但不適用於我將其放在AWS LAMP服務器上的機器。我無法調試任何內容,因爲我在運行腳本時遇到HTTP 500錯誤。但是,我知道PEAR已安裝。PHP PEAR郵件錯誤
代碼:
require_once "Mail.php";
$from = "Email<[email protected]>";
$to = "[email protected]";
$subject = "ERROR REPORT";
$body = "test message";
$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "[email protected]";
$password = "pass1";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("Error message sent!");
}
這似乎是在發送()命令以上竊聽出來。任何關於如何更好地調試的建議?
謝謝!這工作。問題是我沒有安裝Net_SMTP – Steven 2011-05-26 01:10:35