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

yipeiwu_com6年前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>";
//采用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!";
}

相关文章

php ss7.5的数据调用 (笔记)

php ss7.5的数据调用 (笔记)

这几天搞 ss7.5 dz7.2 uc1.5 uchome2.0和自己主站的整合 头都大了 呵呵  好歹是弄的差不多 了 呵呵 记录一下 ss7.5的数据调用  ...

linux下 C语言对 php 扩展

一,搭建php环境下载php 5.2.6 源码 并解压编译安装,搭建php环境二,创建扩展项目进入源码目录cd php5.2.6/ext/./ext_skel --extname=my_...

详解WordPress中用于合成数组的wp_parse_args()函数

wp_parse_args() 函数是 WordPress 核心经常用到的函数,它的用途很多,但最主要用来给一个数组参数(args)绑定默认值。 因为 wp_parse_args() 函...

PHP数据类型的总结分析

PHP共有8中数据类型: 类型名称 类型表示 取值 bool 布尔型 true,false integer 整型 -2147483647-2147483648 string...

PHP静态方法和静态属性及常量属性的区别与介绍

PHP中若使用static关键字来修饰属性、方法,称这些属性、方法为静态属性、静态方法。static关键字声明一个属性或方法是和类相关的,而不是和类的某个特定的实例相关,因此,这类属性或...