袁来如此的工作笔记
袁来如此的工作笔记
竹杖芒鞋轻胜马,谁怕? 一蓑烟雨任平生。

php使用PHPMailer实现qq邮箱ssl方式发送邮件类

浏览量:648

function xmail($to, $title, $msg) {
require_once dirname(__FILE__).'/phpmail/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3;                               // Enable verbose debug output
$mail->CharSet  = 'UTF-8';
$mail->Encoding = 'base64';
$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.qq.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'xxxxxx@qq.com';                 // SMTP username
$mail->Password = 'xxxxxx';                           // SMTP password
$mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465;                                    // TCP port to connect to
$mail->setFrom('xxxxxxx@qq.com', 'xxxxxxx');
$mail->addAddress($to);     // Add a recipient
$mail->isHTML(true);                                  // Set email format to HTML
$mail->Subject = $title;
$mail->Body    = $msg;
if(!$mail->send()) {
   // echo 'Mailer Error: ' . $mail->ErrorInfo;
return false;
} else {
   return true;
}
}


使用:xmail(xxxxxx', $title, $msg)

注意QQ密码是独立密码。


打赏