调用phpmailer发邮件,在本地没问题,放到goddady就出以下错误,有人遇到过吗?请帮忙一下。
SMTP -> ERROR: Failed to connect to server: Connection refused (111) 
SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.我的代码:    $to="[email protected]";
    $body="only a test!";
    error_reporting(E_STRICT);
    date_default_timezone_set("Asia/Shanghai");
    require_once('class.phpmailer.php');
    include("class.smtp.php"); 
    $mail             = new PHPMailer(); 
    $body             = eregi_replace("[\]",'',$body); 
    $mail->CharSet ="UTF-8";
    $mail->IsSMTP(); 
    $mail->SMTPDebug  = 1;                   
                                          // 1 = errors and messages
                                           // 2 = messages only
    $mail->SMTPAuth   = true;                 
    $mail->SMTPSecure = "ssl";                
    $mail->Host       = "SMTP.gmail.com";     
    $mail->Port       = 25;                  
    $mail->Username   = "[email protected]";  // email address
    $mail->Password   = "xxxxxx";            // email password
    $mail->SetFrom('[email protected]', 'lee');
     $mail->Subject    = $subject;
    $mail->AltBody    = "test"; 
    $mail->MsgHTML($body);
    $address = $to;
    $mail->AddAddress($address, "");
    if(!$mail->Send()) {
        echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
        echo "Message sent!";
        }    

解决方案 »

  1.   

    无法连接SMTP服务器。检查参数是否错误。
      

  2.   

    搜索 Failed to connect to server: Connection refused (111) 
    发现很多人遇到这个问题主要的原因是相关端口没有打开
      

  3.   

    goddady上,应该可以直接用mail发,
    连接到smtp服务器,端口基本都是不开的
      

  4.   

    hellpyou0,直接用mail?什么意思,能说详细点吗?
      

  5.   

    http://php.net/manual/en/function.mail.php
      

  6.   

    楼主这个问题后来解决了吗?我用的也是godaddy和PHPMailer,发不了邮件
      

  7.   

    这就很费解了,gmail的smtp,和godaddy没啥关系