Heim  >  Artikel  >  php教程  >  phpMailer使用介绍

phpMailer使用介绍

WBOY
WBOYOriginal
2016-06-08 17:32:251086Durchsuche
<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(

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:PHP实现翻页跳转功能Nächster Artikel:PHP效率优化