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

Hoshi ·
更新时间:2024-09-21
· 697 次阅读

<?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>";
//采用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!";
}
您可能感兴趣的文章:phplist及phpmailer(组合使用)通过gmail发送邮件的配置方法PHP借助phpmailer发送邮件thinkphp使用phpmailer发送邮件的方法phpmailer发送邮件之后,返回收件人是否阅读了邮件的方法phpmailer在服务器上不能正常发送邮件的解决办法php多种形式发送邮件(mail qmail邮件系统 phpmailer类)PHP使用PHPMailer发送邮件的简单使用方法PHPMailer使用教程(PHPMailer发送邮件实例分析)使用 PHPMAILER 发送邮件实例应用PHPMailer邮件类利用smtp.163.com发送邮件方法phpmailer简单发送邮件的方法(附phpmailer源码下载)



.com com 发送邮件 phpmailer 示例 邮件 PHP

需要 登录 后方可回复, 如果你还没有账号请 注册新账号