Heim  >  Artikel  >  Backend-Entwicklung  >  php应用篇 PHPMailer使用

php应用篇 PHPMailer使用

WBOY
WBOYOriginal
2016-06-23 13:50:57883Durchsuche

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";   }?>



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