2017-06-06 167 views
0

我試圖通過使用php郵件通過php發送電子郵件,但它顯示SMTP連接()失敗。這是我的代碼。無法找出那是什麼問題。如果有人幫助追蹤錯誤,那對我來說會非常有幫助。SMTP connect()失敗。雖然發送身份驗證電子郵件顯示coonect()faild

$mail = new PHPMailer; 
$mail->isSMTP();         // Set mailer to use SMTP 
$mail->Host = 'dds.uemtv.com';     // Specify main and backup SMTP servers 
$mail->SMTPAuth = true;       // Enable SMTP authentication 
$mail->Username = '[email protected]';   // SMTP username 
$mail->Password = 'password'; // SMTP password 
$mail->SMTPSecure = 'tls';       // Enable TLS encryption, `ssl` also accepted 
$mail->Port = 465;         // TCP port to connect to 

$mail->setFrom('[email protected]', 'domain'); 
$mail->addReplyTo($email, '$name'); 
$mail->addAddress($email); // Add a recipient 
//$mail->addCC('[email protected]'); 
//$mail->addBCC('[email protected]'); 

$mail->isHTML(true); // Set email format to HTML 

$bodyContent = '<h1>Your Registration Completed. </h1>' 
$mail->Subject = 'Verify Account- Rozgar'; 
$mail->Body = $bodyContent; 
if(!$mail->send()) { 
    echo $data->msg = $mail->ErrorInfo; 
} else { 
    // echo 'Message has been sent'; 
    echo $data->msg="Please Verify Your Email Address"; 
} 
+0

它顯示了SMTP連接()失敗 –

+0

嘗試啓用調試,檢查下列答案https://stackoverflow.com/questions/2896280/debugging-php-mail-and-or-phpmailer – Aboudeh87

回答

0

不要使用隨機設置,並希望它的工作原理。 SMTPSecure = 'tls'將不適用於Port = 465。爲明確的TLS設置Port = 587

通常,使用最新版本,將代碼基於PHPMailer提供的示例,並閱讀錯誤消息所指向的故障排除指南。

+0

沒有那麼工作尚未 –

+0

閱讀[指南](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting),按照說明操作。如果這不能解決問題,請將您的發現添加到您的問題中。 – Synchro