Home  >  Article  >  php教程  >  2013/8/29 TP发送邮件 <技巧类>

2013/8/29 TP发送邮件 <技巧类>

WBOY
WBOYOriginal
2016-06-13 11:31:331085browse

 

1.导入类文件mail,并创建对象

import('ORG.Com.Phpmailer');

$mail=new PHPMailer();

2.设置信息

$mail->IsSMTP();                     //设置使用SMTP服务器发送
$mail->Host = "smtp.126.com";             //设置126邮箱服务
$mail->SMTPAuth = true;                 // 设置需要验证
$mail->Username = "kongxiangshuaihe@126.com";    // 发件人使用邮箱
$mail->Password = "538567";               // 设置发件人密码

$mail->From = "heitiane@126.com";      // 发件人邮箱
$mail->FromName = "yi时网";               //发送者名称
$mail->AddAddress('666@qq.com');              // 添加发送地址

$mail->IsHTML(true);                   //指定支持html格式
$mail->CharSet="UTF-8";                //指定字符集

$mail->Subject = "激活帐号";               //邮件标题   
$mail->Body = "帐号已经激活,点击跳转localhost/demo.jpg";  //邮件内容,可以加标签

3.发送邮件,成功返回true 失败false

 $mail->Send();

 

Statement:
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