<?php
require 'class.phpmailer.php';
try {
$mail = new PHPMailer(true); //New instance, with exceptions enabled $body             = file_get_contents('contents.html');
$body             = preg_replace('/\\\\/','', $body); //Strip backslashes
$mail->IsSMTP();                           // tell the class to use SMTP
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Port       = 25;                    // set the SMTP server port
$mail->Host       = "smtp.qq.com"; // SMTP server
$mail->Username   = "[email protected]";     // SMTP server username
$mail->Password   = "12345in";            // SMTP server password
$mail->IsSendmail();  // tell the class to use Sendmail
$mail->AddReplyTo("[email protected]","First Last");
$mail->From       = "[email protected]";
$mail->FromName   = "wanglingtao";
$to = "[email protected]";
$mail->AddAddress($to);
$mail->Subject  = "First PHPMailer Message";
$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->WordWrap   = 80; // set word wrap
$mail->MsgHTML($body);
$mail->IsHTML(true); // send as HTML
$mail->Send()
echo "Message has been sent";
} catch (phpmailerException $e) {
echo $e->errorMessage();
}
?>

解决方案 »

  1.   

    $mail->Host = "smtp.qq.com"; // SMTP server
    $mail->Username = "[email protected]"; // SMTP server username
    $mail->Password = "12345in"; // SMTP server password
    ==============================
    请问:$mail->Host是指我域名服务器上的smtp吗?
    $mail->Username这个Username帐号是不是要在我服务器上配置,望指教
    $mail->Password 
      

  2.   

    你看看你QQ的SMTP/pop3开通了吗?
      

  3.   

    看看服务器邮件发送的log    通常在/var/log/maillog  
      

  4.   

    表示:
    $mail->Host = "smtp.qq.com"; // 你使用的值 QQ 邮箱的发件服务器
    $mail->Username = "[email protected]"; // 这个就应该是你的QQ邮箱的账号
    $mail->Password = "12345in"; // 这个就是你登录你的QQ邮箱的密码
      

  5.   

    换个126,gmail试试吧。估计qq不支持