php应用篇 PHPMailer使用

WBOY
Release: 2016-06-23 13:50:57
Original
921 people have browsed it

PHPMailer是php中发送邮件的非常好用的类,里面封装了很多重要函数和功能,让我们发送邮件,以及调整邮件中的内容变得非常容易,下面给出一个PHPMailer的一个测试用例,方便以后查询使用。


首先,需要下载PHPMailer这个类库,可以从github上现在,解压后就可以使用了。


下载地址:https://github.com/PHPMailer/PHPMailer


下面给出程序:这里使用qq邮箱进行测试,需要去邮箱里面

设置=》账户=》POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务中 

勾选POP3/SMTP服务。


<?php include "class.phpmailer.php";  $mail= new PHPMailer();  $mail->IsSMTP();  $mail->SMTPDebug = 2;  $mail->Host = "smtp.qq.com";  $mail->Port = "465";    $mail->SMTPSecure = "ssl";  $mail->SMTPAuth = true;  $mail->Username = "470356072";//username  $mail->Password = "******";//repalce your password  $mail->AddReplyTo("470356072@qq.com", "网络");  $mail->AddAddress('<span style="font-family: Arial, Helvetica, sans-serif;">470356072</span>@qq.com');  $mail->SetFrom("470356072@qq.com", "网络");  $mail->IsHTML(false);  $mail->Subject = "测试邮件";  $mail->MsgHTML("这是一封测试邮件!");  $mail->Send();  if($mail->Send()){      echo "success";    } else {    echo "false";   }?>
Copy after login



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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template