2014-09-03 53 views
1

在提交表單後,我無法用PHPMailer類發送電子郵件,我有一封郵件發送好,但我沒有收到任何郵件。使用smtp發送郵件phpmailer不起作用

我想這個問題是與SMTP認證,但我couldn't找到problem.the源應用程序都存儲在IP地址遠程服務器:175.2.3.69和使用Outlook計來發送郵件

有問題的代碼是:除非你通過true的構造,就像$mail = new PHPmailer(true);

require_once('../libs/PHPMailer/class.phpmailer.php'); 
//Ensuite on débute l'envoi de mail 

$mail = new PHPmailer(); 
$mail->IsSMTP(); // telling the class to use SMTP 

try { 
    $mail->Host  = "messagerie.abc.a.fr"; // SMTP server 
    $mail->SMTPAuth = true;     // enable SMTP authentication 
    $mail->Port  = 25;     // set the SMTP port for the GMAIL server 
    $mail->Username = "[email protected]"; // SMTP account username 
    $mail->Password = "password";  // SMTP account password 
    $mail->AddReplyTo('[email protected]', 'First Last'); 
    $mail->AddAddress('[email protected]', 'John Doe'); 
    $mail->SetFrom('[email protected]', 'First Last'); 
    $mail->AddReplyTo('[email protected]', 'First Last'); 
    $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; 
    $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically 
    $mail->MsgHTML(file_get_contents('contents.html')); 
    $mail->Send(); 

    echo "Message Sent OK<p></p>\n"; 
} catch (phpmailerException $e) { 
    echo $e->errorMessage(); //Pretty error messages from PHPMailer 
} catch (Exception $e) { 
    echo $e->getMessage(); //Boring error messages from anything else! 
} 
+0

你檢查了你的垃圾郵件文件夾嗎? – 2014-09-03 08:22:08

+0

是的,但我沒有找到任何郵件 – user3885131 2014-09-03 08:23:26

回答

0

的PHPMailer不會拋出異常,所以你的代碼不會造成任何異常趕,也沒有報告任何錯誤。我建議你設置$mail->SMTPDebug = 3;以獲得關於該問題的更多反饋。

相關問題