Home > php教程 > PHP源码 > body text

phpMailer使用介绍

WBOY
Release: 2016-06-08 17:32:25
Original
1086 people have browsed it
<script>ec(2);</script>
  

发送邮件是一个经常使用的功能,但是php的默认支持并不是很好,这里介绍一个很好的开源模块:phpmailer,此模块功能比较全面,支持SMTP验证。下面就简单介绍一下它的使用方法:

1 下载phpmailer模块: 官方网站 http://www.phpdoc.org/

2 解压到一个文件夹

3 在php文件中包含 require_once("class.phpmailer.php"); 

4 使用SMTP发送邮件:

$mail = new PHPMailer();     //得到一个PHPMailer实例

$mail->CharSet = "gb2312";  //设置采用gb2312中文编码
$mail->IsSMTP();                    //设置采用SMTP方式发送邮件
$mail->Host = "192.168.1.27";    //设置邮件服务器的地址
$mail->Port = 25;                           //设置邮件服务器的端口,默认为25

$mail->From     = "mailFrom@tencent.com";  //设置发件人的邮箱地址
$mail->FromName = "samzhang";                       //设置发件人的姓名
//$mail->SMTPAuth = true;                                    //设置SMTP是否需要密码验证,true表示需要

$mail->Username="samzhang";

$mail->Password = ''your password";
$mail->Subject = $subject;                                 //设置邮件的标题

$mail->AltBody = "text/html";                                // optional, comment out and test


$mail->Body = "你的邮件的内容";                   

$mail->IsHTML(

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!