我已經從github下載了PHPMailer
庫,並使用以下腳本發送郵件。我試圖發送電子郵件到我自己的帳戶,它的工作。它打印了「消息已發送」並在Gmail中收到了電子郵件。但是,當我嘗試將郵件發送給我的朋友的帳戶時,他沒有收到郵件。但腳本說消息已發送。無法將郵件發送給我自己以外的其他帳戶?
<?php
include('PHPMailer-master/PHPMailerAutoload.php');
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "[email protected]";
$mail->Password = "examplepassword";
$mail->SetFrom("[email protected]");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("[email protected]");
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>
我正在使用xampp。問題背後的原因是什麼,我需要更改我的Gmail設置中的任何設置嗎?
編輯:現在,我得到郵件到第二個地址,但後40分鐘。但是,當我發送它的第一個地址時,它會立即收到。不知道爲什麼?我想用它來驗證電子郵件地址,40分鐘很長。
支票垃圾/垃圾郵件文件夾?你的電子郵件也在Gmail嗎? – user12
@ user12我已經在垃圾郵件文件夾中檢查過...... yes..gmail – pinkpanther