這裏是我的PHP代碼:PHP梅勒無法連接到服務器
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->CharSet="UTF-8";
$mail->SMTPSecure = 'ssl';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = '[email protected]';
$mail->Password = 'pw';
$mail->SMTPAuth = true;
$mail->From = '[email protected]';
$mail->FromName = 'Clubbed In';
$mail->AddAddress('[email protected]');
$mail->AddReplyTo('[email protected]', 'Information');
$mail->IsHTML(true);
$mail->Subject = "PHPMailer Test Subject via Sendmail, basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->Body = "Hello";
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message sent!";
}
我跟着一個Gmail的PHPMailer教程,我不知道什麼是錯的?有人可以幫忙嗎?
你遵循了一個過時的教程。在[本示例](https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps)和[閱讀這些文檔](https://github.com/PHPMailer/PHPMailer) /維基/故障檢測)。 – Synchro