public function mail() {
header('Content-type:text/html;charset=utf-8');
vendor("PHPMailer.class#phpmailer"); //从PHPMailer目录导入class.phpmailer.php类文件
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
try {
$mail->Host = "smtp.qq.com"; // SMTP server 部分邮箱不支持SMTP,QQ邮箱里要设置开启的
$mail->SMTPDebug = false; // 改为2可以开启调试
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "smtp.qq.com"; // sets the SMTP server
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->CharSet = "UTF-8"; // 这里指定字符集!解决中文乱码问题
$mail->Encoding = "base64";
$mail->Username = "370513625"; // SMTP account username
$mail->Password = "密码"; // SMTP account password
$mail->AddAddress('pingguotu@qq.com', '苹果兔');
$mail->SetFrom('370513625@qq.com', 'verycover'); //发送者邮箱
$mail->AddReplyTo('370513625@qq.com', 'verycover'); //回复到这个邮箱
$mail->Subject = 'helo word';
$body = "正文sss";
$mail->MsgHTML($body);
//$mail->AddAttachment('images/phpmailer.gif'); // attachment
// $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
$mail->Send();
echo "Message Sent OK</p>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
}