php群发邮件
git上下載phpmailer
[添加鏈接描述](https://github.com/PHPMailer/PHPMailer)
<?php
require_once("PHPMailer-master/src/PHPMailer.php");
require_once("PHPMailer-master/src/SMTP.php");$title = "節日快樂";
$content = "祝你程序節快樂";
$to = "614223981@qq.com";
print_r(sendMail($title,$content,$to));function sendMail($title,$content,$to)
{
$mail = new PHPMailer();
$mail -> IsSMTP(); //告訴服務器使用smtp協議發送
$mail -> SMTPAuth = true; //開啟SMTP授權
$mail -> Host = 'smtp.qq.com'; //告訴我們的服務器使用163的smtp服務器發送
$mail -> From = ''; //發送者的郵件地址
$mail -> FromName = 'dream it possible'; //發送郵件的用戶昵稱
$mail -> Username = ''; //登錄到郵箱的用戶名
$mail -> Password = ''; //第三方登錄的授權碼,在郵箱里面設置
//編輯發送的郵件內容
$mail -> IsHTML(true); //發送的內容使用html編寫
$mail -> CharSet = 'utf-8'; //設置發送內容的編碼
$mail -> Subject = $title; //設置郵件的主題、標題
$mail -> MsgHTML($content); //發送的郵件內容主體
//告訴服務器接收人的郵件地址
$mail -> AddAddress($to);
//調用send方法,執行發送
$result = $mail -> Send();
if($result){
return true;
}else{
return $mail -> ErrorInfo;
}}
總結
- 上一篇: redis消息队列
- 下一篇: 安装vue脚手架创建项目