切换导航条
此项目
正在载入...
登录
周海龙
/
mail-serve
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
邓超
about a year ago
提交
19ccbc8170fe5d3be9446b0111cdc9030999ae54
1 个父辈
c3b945a5
添加端口
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
19 行增加
和
3 行删除
lib/Mail/MailFun.php
lib/Mail/MailFun.php
查看文件 @
19ccbc8
...
...
@@ -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
,
];
}
}
...
...
请
注册
或
登录
后发表评论