我發送電子郵件從本地主機通過Gmail使用PHP郵件這是我的代碼,但主要問題是,當我運行腳本沒有告訴我任何錯誤,我沒有收到在Gmail ID的任何電子郵件使用PHP郵件發送電子郵件從本地主機到Gmail地址
include("email/class.phpmailer.php");
$mail = new PHPMailer();
$body = "This is just a Test Email";
$mail->IsSMTP();
// enable SMTP authentication
$mail->SMTPAuth = true;
// sets GMAIL as the SMTP server
$mail->Host = "smtp.gmail.com";
// set the SMTP port for the GMAIL server
$mail->Port = 465;
// GMAIL username
$mail->Username = "Mygmail id";
// GMAIL password
$mail->Password = "password";
$mail->From = "Mygmail id";
$mail->FromName = "My Name";
$mail->Subject = "Testing Message";
$mail->AltBody = "To view the message, please use an HTML compatible
email viewer!"; // optional, comment out and test
$mail->WordWrap = 50; // set word wrap
$mail->MsgHTML($body);
$mail->AddAddress("Receiver Gmail Id");
$mail->IsHTML(true); // send as HTML
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
而且請不要讓我爲重複的問題東陽我嘗試了所有其他的答案,但沒有找到任何解決方案
這是一個重複的內容,[在文檔](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting)中有廣泛的報道,您使用的是舊版本的PHPMailer,並且未能使用[gmail示例提供](https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps)。一般來說,它看起來並不像你很努力。 – Synchro