2014-02-25 21 views
0

我已經從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分鐘很長。

+0

支票垃圾/垃圾郵件文件夾?你的電子郵件也在Gmail嗎? – user12

+0

@ user12我已經在垃圾郵件文件夾中檢查過...... yes..gmail – pinkpanther

回答

0

下面的鏈接將幫助您: 通過PHP郵件發送的電子郵件是緩慢

http://stackoverflow.com/questions/6380477/sending-emails-through-php-mail-is-slow 
+0

我的問題不是緩慢的腳本.....我的問題是與接收電子郵件....當我發送電子郵件給我自己的地址,它發送和接收速度很快。當我向他人發送郵件時,腳本立即執行,但郵件在超過15分鐘後收到收件人的Gmail收件箱 – pinkpanther

相關問題