2014-11-08 273 views
0

我試圖通過smtp發送電子郵件,但不幸的是,它沒有被髮送。似乎沒有錯誤。我哪裏有錯誤?SMTP電子郵件不發送

require("class.phpmailer.php"); 

$mail = new PHPMailer(); 

$mail->IsSMTP();         // send via SMTP 
$mail->Host  = "mail.site.org"; // SMTP servers 
$mail->SMTPAuth = true;  // turn on SMTP authentication 
$mail->Username = "[email protected]"; // SMTP username 
$mail->Password = "123456"; // SMTP password 

$mail->From  = "[email protected]"; // smtp kullanıcı adınız ile aynı olmalı 
$mail->Fromname = "giden ismi"; 
$mail->AddAddress("[email protected]","Ornek Isim"); 
$mail->Subject = $_POST['baslik']; 
$mail->Body  = implode(" ",$_POST); 

if(!$mail->Send()) 
{ 
    echo "Mail couldnt send <p>"; 
    echo "Mailer Error: " . $mail->ErrorInfo; 
    exit; 
} 

echo "Mail sent"; 
+0

那麼什麼是輸出?你看到'Mail couldnt send'消息或'Mail sent'消息嗎? – Jordan 2014-11-08 23:31:43

+0

你有SMTP服務器嗎?日誌裏有什麼? – andrewsi 2014-11-08 23:54:55

+0

是的,我有Smtp服務器。我在網上使用檢查腳本檢查它。問題是發送郵件後。我收到「消息發送」報告,但我沒有收到郵件。 – bodrumlife 2014-11-09 01:02:07

回答

1

試試這個,讓錯誤:

當你運行它
require("class.phpmailer.php"); 

$mail = new PHPMailer(true); 
try { 
$mail->IsSMTP();         // send via SMTP 
$mail->Host  = "mail.site.org"; // SMTP servers 
$mail->SMTPAuth = true;  // turn on SMTP authentication 
$mail->Username = "[email protected]"; // SMTP username 
$mail->Password = "123456"; // SMTP password 

$mail->From  = "[email protected]"; // smtp kullanıcı adınız ile aynı olmalı 
$mail->Fromname = "giden ismi"; 
$mail->AddAddress("[email protected]","Ornek Isim"); 
$mail->Subject = $_POST['baslik']; 
$mail->Body  = implode(" ",$_POST); 
$mail->Send(); 
echo "Message Sent OK\n"; 
} 
catch (phpmailerException $e) { 
    echo $e->errorMessage(); 
} 
catch (Exception $e) { 
    echo $e->getMessage(); 
} 
+0

感謝您的幫助。發送這個之後,我收到了「消息發送」報告。但不要郵寄到我的郵箱。 – bodrumlife 2014-11-09 01:03:55

+0

什麼都出現在你的SMTP日誌中? – EdvinasJ 2014-11-09 12:36:25