Mail.class.phpphp
<?php
header("content-type:text/html;charset=utf-8");
//引入原来的类文件
require 'class.phpmailer.php';
class Mail {
static public $error = '';
static public function send($title,$content,$user,$address){
$mail= new PHPMailer();
/*服务器相关信息*/
$mail->IsSMTP(); //设置使用SMTP服务器发送
$mail->SMTPAuth = true; //开启SMTP认证
$mail->Host = 'smtp.163.com'; //设置 SMTP 服务器,本身注册邮箱服务器地址 QQ则是ssl://smtp.qq.com
$mail->Port = 25;
$mail->Username = '............'; //发信人的邮箱名称,本人网易邮箱 zzy9i7@163.com 这里就写
$mail->Password = '............'; //发信人的邮箱密码
//$mail->SMTPSecure = 'tls';
/*内容信息*/
$mail->IsHTML(true); //指定邮件格式为:html *不加true默认为以text的方式进行解析
$mail->CharSet ="UTF-8"; //编码
$mail->From = "....."; //发件人完整的邮箱名称
$mail->FromName = $user; //发信人署名
$mail->Subject = $title; //信的标题
$mail->MsgHTML($content); //发信主体内容
//$mail->AddAttachment("15.jpg"); //附件
/*发送邮件*/
$mail->AddAddress($address); //收件人地址
//使用send函数进行发送
if($mail->Send()) {
return true;
} else {
self::$error=$mail->ErrorInfo;
return false;
}
}
}
?>html
最后在须要的发送邮件的php中服务器
Mail::send($title,$content,$user,$address);函数
其中若是遇到报错什么的.百度吧 ,不少人都解决过的.ui