正在显示
1 个修改的文件
包含
19 行增加
和
3 行删除
| @@ -266,18 +266,18 @@ class MailFun { | @@ -266,18 +266,18 @@ class MailFun { | ||
| 266 | * @time 2023/11/7 10:47 | 266 | * @time 2023/11/7 10:47 |
| 267 | */ | 267 | */ |
| 268 | public static function smtpLoginTest($smtp,$email,$password){ | 268 | public static function smtpLoginTest($smtp,$email,$password){ |
| 269 | - | 269 | + $smtp = self::getHostPort($smtp,465); |
| 270 | // 邮件对象 | 270 | // 邮件对象 |
| 271 | $mail = new PHPMailer(); | 271 | $mail = new PHPMailer(); |
| 272 | //Server settings | 272 | //Server settings |
| 273 | $mail->SMTPDebug = SMTP::DEBUG_OFF;//调试输出 SMTP::DEBUG_SERVER; //Enable verbose debug output | 273 | $mail->SMTPDebug = SMTP::DEBUG_OFF;//调试输出 SMTP::DEBUG_SERVER; //Enable verbose debug output |
| 274 | $mail->isSMTP(); //Send using SMTP | 274 | $mail->isSMTP(); //Send using SMTP |
| 275 | - $mail->Host = $smtp; //Set the SMTP server to send through | 275 | + $mail->Host = $smtp['host']; //Set the SMTP server to send through |
| 276 | $mail->SMTPAuth = true; //Enable SMTP authentication | 276 | $mail->SMTPAuth = true; //Enable SMTP authentication |
| 277 | $mail->Username = $email; //SMTP username | 277 | $mail->Username = $email; //SMTP username |
| 278 | $mail->Password = $password; //SMTP password | 278 | $mail->Password = $password; //SMTP password |
| 279 | $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption | 279 | $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption |
| 280 | - $mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` | 280 | + $mail->Port = $smtp['port']; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` |
| 281 | $mail->CharSet = 'utf-8'; | 281 | $mail->CharSet = 'utf-8'; |
| 282 | $mail->Encoding = PHPMailer::ENCODING_QUOTED_PRINTABLE; | 282 | $mail->Encoding = PHPMailer::ENCODING_QUOTED_PRINTABLE; |
| 283 | 283 | ||
| @@ -290,4 +290,20 @@ class MailFun { | @@ -290,4 +290,20 @@ class MailFun { | ||
| 290 | } | 290 | } |
| 291 | 291 | ||
| 292 | 292 | ||
| 293 | + /** | ||
| 294 | + * @param $host | ||
| 295 | + * @param int $port | ||
| 296 | + * @return array | ||
| 297 | + * @author:dc | ||
| 298 | + * @time 2024/3/6 9:21 | ||
| 299 | + */ | ||
| 300 | + public static function getHostPort($host,$port = 465){ | ||
| 301 | + list($h,$p) = explode(":",$host.':'.$port); | ||
| 302 | + return [ | ||
| 303 | + 'host' => $h, | ||
| 304 | + 'port' => $p, | ||
| 305 | + ]; | ||
| 306 | + } | ||
| 307 | + | ||
| 308 | + | ||
| 293 | } | 309 | } |
-
请 注册 或 登录 后发表评论