解析php中用PHPMailer来发送邮件的示例(126.com的例子)
时间:2020-04-27 13:37 来源/作者:PHP教程网
-
<?php
-
require_once('../class.phpmailer.php');
-
$mail= new PHPMailer();
-
$body= "我终于发送邮件成功了!呵呵!goodboy xxxxxxx!<br/><a>http://news.qq.com/a/20111115/000792.htm?qq=0&ADUIN=594873950&ADSESSION=1321316731&ADTAG=CLIENT.QQ.3493_.0</a>";
-
-
$mail->IsSMTP();
-
-
$mail->Host = "smtp.126.com";
-
$mail->SMTPDebug = 0;
-
-
$mail->SMTPAuth = true;
-
-
$mail->Username = "xxxxxxx@126.com";
-
-
$mail->Password = "password";
-
-
$mail->CharSet = "utf-8";
-
-
$mail->Subject = "测试";
-
-
-
$mail->SetFrom('xxxxxxx@126.com', 'test');
-
-
$mail->MsgHTML($body);
-
-
$mail->AddAddress("xxxxxxx@126.com", "test");
-
if(!$mail->Send()) {
-
echo "Mailer Error: " . $mail->ErrorInfo;
-
} else {
-
echo "Message sent!";
-
}
相关文章
热门资讯