Home > php教程 > php手册 > body text

解析php中用PHPMailer来发送邮件的示例(126.com的例子)

WBOY
Release: 2016-06-13 11:45:45
Original
1129 people have browsed it

require_once('../class.phpmailer.php');
$mail= new PHPMailer();
$body= "我终于发送邮件成功了!呵呵!goodboy xxxxxxx!
http://news.qq.com/a/20111115/000792.htm?qq=0&ADUIN=594873950&ADSESSION=1321316731&ADTAG=CLIENT.QQ.3493_.0";
//采用SMTP发送邮件
$mail->IsSMTP();
//邮件服务器
$mail->Host       = "smtp.126.com";
$mail->SMTPDebug  = 0;
//使用SMPT验证
$mail->SMTPAuth   = true;
//SMTP验证的用户名称
$mail->Username   = "xxxxxxx@126.com";
//SMTP验证的秘密
$mail->Password   = "password";
//设置编码格式
$mail->CharSet  = "utf-8";
//设置主题
$mail->Subject    = "测试";
//$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!";
//设置发送者
$mail->SetFrom('xxxxxxx@126.com', 'test');
//采用html格式发送邮件
$mail->MsgHTML($body);
//接受者邮件名称
$mail->AddAddress("xxxxxxx@126.com", "test");//发送邮件
if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template