嗨我正在使用phpMailer發送電子郵件。它在服務器上工作正常,但是當我試圖從本地機器(本地主機)發送郵件時,它給我錯誤。我使用Gmail SMTPPHP郵件程序SMTP錯誤
<?
require("lib/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Mailer = "smtp";
$mail->Host = "ssl://smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = "XXXXXXX"; // SMTP password
$mail->From = $email;
$mail->AddAddress("[email protected]", "XX XX XX");
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = "You have received feedback from your website!";
$mail->Body = $message;
$mail->AltBody = $message;
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
}
?>
,誤差
SMTP Error: Could not connect to SMTP host. Message could not be sent.
Mailer Error: SMTP Error: Could not connect to SMTP host.
它在我的服務器工作正常。
那你的互聯網連接的代碼,你使用防火牆或一些東西可以嘗試禁用它 –
我不認爲'SSL: // smtp.gmail.com'是一個主機名。 –
@ aravind.udayashankara我關掉了防火牆...... :-( – Rakesh