12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- /**
- * User: wangsai
- * Date: 2019/11/5
- * Time: 14:45
- */
- namespace App\Support;
- include_once(__DIR__.'/ClassPhpMailer.php');
- class Email
- {
- private static $_smpt = "smtp.exmail.qq.com";
- private static $_account = "ldscript@kuxuan-inc.com";
- private static $_pwd = "Kuxuan2019";
- /**
- * @param $title
- * @param $content
- * @param $emails
- * @param $sender
- * @return mixed
- */
- public static function send($title, $content, $emails, $sender = null)
- {
- $mail = new \PHPMailer(); //PHPMailer对象
- $mail->CharSet = 'utf-8'; //设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码
- $mail->Encoding = "base64";
- $mail->IsSMTP(); // 设定使用SMTP服务
- $mail->SMTPDebug = 0; // 关闭SMTP调试功能
- $mail->SMTPAuth = true; // 启用 SMTP 验证功能
- $mail->SMTPSecure = 'ssl'; // 使用安全协议
- $mail->Port = "465"; // SMTP服务器的端口号
- $mail->Host = self::$_smpt; // SMTP 服务器
- $mail->Username = self::$_account; // SMTP服务器用户名
- $mail->Password = self::$_pwd; // SMTP服务器密码
- $mail->Subject = $title; //邮件标题
- $sender = $sender ?: $title;
- $mail->SetFrom($mail->Username, $sender);
- $mail->MsgHTML($content);
- $emails = (array) $emails;
- foreach ($emails as $email) {
- $mail->AddAddress($email);
- }
- return $mail->Send() ? true : $mail->ErrorInfo;
- }
- }
|