$mail->Host = "SMTP.163.com";

解决方案 »

  1.   

    <?
    require "phpmailer/class.phpmailer.php";
    $mail = new PHPMailer();
    $mail->IsSMTP();        // set mailer to use SMTP
    $mail->Host = "SMTP.163.com";  // 邮件供应商的服务器地址   specify main and backup server
    $mail->SMTPAuth = true;     // 验证开启  turn on SMTP authentication
    $mail->Username = "cy14yang";  // 你的邮箱用户名    SMTP username
    $mail->Password = "*********"; // 你的邮箱密码    SMTP password$mail->From = "[email protected]";   //发件箱地址
    $mail->FromName = "cy14yang";                //发送者姓名
    $mail->AddAddress("[email protected]", "ad");  //收件箱地址
    //$mail->AddAddress("[email protected]");                  // name is optional
    //$mail->AddReplyTo("[email protected]", "Information");$mail->WordWrap = 50;                                 // set word wrap to 50 characters
    //$mail->AddAttachment("file.txt");         // 添加附件   add attachments
    //$mail->AddAttachment("/tmp/image.jpg", "new.jpg");    // optional name
    $mail->IsHTML(true);                                  // set email format to HTML$mail->Subject = "Here is the subject1111111111111111";  //邮件标题
    $mail->Body    = "This is the HTML message body 111111111<b>in bold!</b>";   //邮件内容可带HTML
    $mail->AltBody = "This is the body in plain text for non-HTML mail clients";  //邮件内容不带HTMLif(!$mail->Send())
    {
       echo "Message could not be sent. <p>";
       echo "Mailer Error: " . $mail->ErrorInfo;
       exit;
    }else{echo "Message has been sent";}
    ?> 
      

  2.   

    为什么产生 
    Message could not be sent. 
    Mailer Error: SMTP Error: Could not connect to SMTP host.
     
      

  3.   

    可以用outlook测试一下,你的机器能否使用smtp.163.com来发送邮件。
      

  4.   

    我发现在 
    phpinfo()中没有
    Sockets Support  = enable
    为什么
      

  5.   

     找到了 有这个 Sockets Support  = enable 但还是不行的 
      

  6.   

    编译PHP的时候,需要带上--enable-sockets。
      

  7.   

    linux下重新编译一下php 并且在编译的时候加上--enable-sockets参数.
    windows上直接去掉php.ini中关于socket的dll.
      

  8.   

    把这个 extension=php_sockets.dll 去掉?????????
      

  9.   

    对,去掉重启.
    并且确定php_sockets.dll 在正确的目录.
      

  10.   

    $mail->Username = "cy14yang";  // 你的邮箱用户名    SMTP username 
    改成 $mail->Username = "[email protected]";
    再试试。