...
|
...
|
@@ -266,18 +266,18 @@ class MailFun { |
|
|
* @time 2023/11/7 10:47
|
|
|
*/
|
|
|
public static function smtpLoginTest($smtp,$email,$password){
|
|
|
|
|
|
$smtp = self::getHostPort($smtp,465);
|
|
|
// 邮件对象
|
|
|
$mail = new PHPMailer();
|
|
|
//Server settings
|
|
|
$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->Host = $smtp['host']; //Set the SMTP server to send through
|
|
|
$mail->SMTPAuth = true; //Enable SMTP authentication
|
|
|
$mail->Username = $email; //SMTP username
|
|
|
$mail->Password = $password; //SMTP password
|
|
|
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
|
|
|
$mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
|
|
|
$mail->Port = $smtp['port']; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
|
|
|
$mail->CharSet = 'utf-8';
|
|
|
$mail->Encoding = PHPMailer::ENCODING_QUOTED_PRINTABLE;
|
|
|
|
...
|
...
|
@@ -290,4 +290,20 @@ class MailFun { |
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @param $host
|
|
|
* @param int $port
|
|
|
* @return array
|
|
|
* @author:dc
|
|
|
* @time 2024/3/6 9:21
|
|
|
*/
|
|
|
public static function getHostPort($host,$port = 465){
|
|
|
list($h,$p) = explode(":",$host.':'.$port);
|
|
|
return [
|
|
|
'host' => $h,
|
|
|
'port' => $p,
|
|
|
];
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|