错误:SMTP连接()失败

时间:2014-02-28 09:34:18

标签: php smtp

我是新的php和我正在做一个使用smtp gmail发送电子邮件的表单,我在webfreehosting.ne上有一个网站。

当我尝试发送表单时出现错误:错误:SMTP connect()失败。

<?php
 include("class.phpmailer.php"); 
 include("class.smtp.php"); 
 $mail = new PHPMailer(); 
 $mail->IsSMTP(); 
 $mail->SMTPAuth = true; 
 $mail->SMTPSecure = "tls"; 
 $mail->Host = "smtp.gmail.com"; 
 $mail->Port = 465; 
 $mail->Username = "secret@gmail.com"; 
 $mail->Password = "secret";


 $maidl = $_POST["msj"];

 $mail->From = "secret@gmail.com"; 
 $mail->FromName = "Anonymous"; 
 $mail->Subject = "Anonymous "; 
 $mail->AltBody = "Anonymous   ."; 
 $mail->MsgHTML("<b> $maidl </b>.");  
 $mail->AddAddress("secret@gmail.com", "Anonymous "); 
 $mail->IsHTML(true); 
 if(!$mail->Send()) { 
 echo "Error: " . $mail->ErrorInfo; 
 } else { 
 echo "menssage send"; 
 }
 ?>

0 个答案:

没有答案