作者 邓超

添加端口

@@ -157,18 +157,18 @@ class MailFun { @@ -157,18 +157,18 @@ class MailFun {
157 * @time 2023/4/11 9:12 157 * @time 2023/4/11 9:12
158 */ 158 */
159 public static function sendEmail(array $data, array $email){ 159 public static function sendEmail(array $data, array $email){
160 - 160 + $smtp = self::getHostPort($email['smtp'],465);
161 // 邮件对象 161 // 邮件对象
162 $mail = new PHPMailer(); 162 $mail = new PHPMailer();
163 //Server settings 163 //Server settings
164 $mail->SMTPDebug = SMTP::DEBUG_OFF;//调试输出 SMTP::DEBUG_SERVER; //Enable verbose debug output 164 $mail->SMTPDebug = SMTP::DEBUG_OFF;//调试输出 SMTP::DEBUG_SERVER; //Enable verbose debug output
165 $mail->isSMTP(); //Send using SMTP 165 $mail->isSMTP(); //Send using SMTP
166 - $mail->Host = $email['smtp']; //Set the SMTP server to send through 166 + $mail->Host = $smtp['host']; //Set the SMTP server to send through
167 $mail->SMTPAuth = true; //Enable SMTP authentication 167 $mail->SMTPAuth = true; //Enable SMTP authentication
168 $mail->Username = $email['email']; //SMTP username 168 $mail->Username = $email['email']; //SMTP username
169 $mail->Password = base64_decode($email['password']); //SMTP password 169 $mail->Password = base64_decode($email['password']); //SMTP password
170 $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption 170 $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
171 - $mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` 171 + $mail->Port = $smtp['port']; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
172 $mail->CharSet = 'utf-8'; 172 $mail->CharSet = 'utf-8';
173 $mail->Encoding = PHPMailer::ENCODING_QUOTED_PRINTABLE; 173 $mail->Encoding = PHPMailer::ENCODING_QUOTED_PRINTABLE;
174 174