function sendMail($title, $content, $from, $to, $charset='utf-8', $attachment='123.gif'){
include 'class.phpmailer.php';
header('Content-Type:text/html;charset='.$charset);
$mail = new PHPMailer();
$mail->CharSet = $charset;//设置编码
$mail->IsSMTP();//设置用SMTP方式发送邮件
$mail->Host = 'smtp.163.com';//设置邮件服务器地址
$mail->Port = 25;//设置邮件服务器端口,默认25
$mail->From = $from;//设置发件人的邮箱地址
$mail->FromName = '';//设置发件人的姓名
$mail->SMTPAuth = true;//设置SMTP是否需要密码验证
$mail->Username = 'Username';//设置邮箱用户名
$mail->Password = '**********';//设置邮箱登录密码
$mail->Subject = 'Email Title';//邮件标题
$mail->AltBody = 'text/html';//
$mail->Body = $content;//邮件内容
$mail->isHTML(true);//设置内容是否为html类型
$mail->WordWrap = 50;//设置每行字符数
//$mail->AddReplyTo('地址','名字');//设置回复的收件人的地址
$mail->AddAddress($to,'目标地址');//设置收件的地址
//附件
if($attachment!=''){
$mail->AddAttachment($attachment,$attachment);
}
if(!$mail->Send()){
echo 'Error';
}else{
echo 'Success';
}
}
sendMail('PHPMailer Test','Test Content','username@163.com','username@qq.com');