...
|
...
|
@@ -121,6 +121,7 @@ class MailFun { |
|
|
|
|
|
|
|
|
/**
|
|
|
* 发送邮件
|
|
|
* @param string $smtp smtp服务器地址
|
|
|
* @param string $username 发件人
|
|
|
* @param string $password 发件人密码
|
...
|
...
|
@@ -131,17 +132,17 @@ class MailFun { |
|
|
* @param array $files 文件 ['origin_name'=>'','path'=>'']
|
|
|
* @param false $receipt 是否回执
|
|
|
* @param int $priority 是否紧急 1紧急 3正常 5慢
|
|
|
* @return bool
|
|
|
* @return array
|
|
|
* @throws \PHPMailer\PHPMailer\Exception
|
|
|
* @author:dc
|
|
|
* @time 2022/11/11 14:26
|
|
|
* @time 2023/2/18 17:45
|
|
|
*/
|
|
|
public static function sendEmail(string $smtp,string $username,string $password,string $nickname,$to_email,string $subject,string $body,$files=[],$receipt=false,$priority=3){
|
|
|
public static function sendEmail(string $smtp,string $username,string $password,string $nickname,string|array $to_email,string $subject,string $body,$files=[],$receipt=false,$priority=3){
|
|
|
|
|
|
// 邮件对象
|
|
|
$mail = new PHPMailer(true);
|
|
|
$mail = new PHPMailer();
|
|
|
//Server settings
|
|
|
$mail->SMTPDebug = SMTP::DEBUG_CLIENT;//调试输出 SMTP::DEBUG_SERVER; //Enable verbose debug output
|
|
|
$mail->SMTPDebug = SMTP::DEBUG_OFF;//调试输出 SMTP::DEBUG_SERVER; //Enable verbose debug output
|
|
|
$mail->isSMTP(); //Send using SMTP
|
|
|
$mail->Host = $smtp; //Set the SMTP server to send through
|
|
|
$mail->SMTPAuth = true; //Enable SMTP authentication
|
...
|
...
|
@@ -193,10 +194,10 @@ class MailFun { |
|
|
|
|
|
// 发送
|
|
|
if($mail->send()){
|
|
|
return true;
|
|
|
return [true,$mail->getLastMessageID()];
|
|
|
}
|
|
|
|
|
|
throw new \Exception($mail->ErrorInfo,500);
|
|
|
return [false,$mail->ErrorInfo];
|
|
|
|
|
|
}
|
|
|
|
...
|
...
|
|