作者 邓超

x

@@ -1030,11 +1030,15 @@ class Imap { @@ -1030,11 +1030,15 @@ class Imap {
1030 private function socketOpen(int $timeout = 30){ 1030 private function socketOpen(int $timeout = 30){
1031 if(!is_resource($this->socket)){ 1031 if(!is_resource($this->socket)){
1032 $this->timeout = $timeout ? : 30; 1032 $this->timeout = $timeout ? : 30;
  1033 +
  1034 + // 是否验证证书
  1035 + $isssl = in_array(parse_url($this->host)['host']??'1-1',['mail.laser-tech.com.cn']);
  1036 +
1033 // 链接服务器 1037 // 链接服务器
1034 $this->socket = stream_socket_client($this->host, $errno, $error, $this->timeout,STREAM_CLIENT_CONNECT,stream_context_create([ 1038 $this->socket = stream_socket_client($this->host, $errno, $error, $this->timeout,STREAM_CLIENT_CONNECT,stream_context_create([
1035 'ssl' => [ 1039 'ssl' => [
1036 - 'verify_peer' => false, // 有的证书和域名不匹配,这里关闭认证  
1037 - 'verify_peer_name' => false,// 有的证书和域名不匹配,这里关闭认证 1040 + 'verify_peer' => !$isssl, // 有的证书和域名不匹配,这里关闭认证
  1041 + 'verify_peer_name' => !$isssl,// 有的证书和域名不匹配,这里关闭认证
1038 // 'capture_peer_cert' => true, 1042 // 'capture_peer_cert' => true,
1039 // 'capture_peer_cert_chain' => true, 1043 // 'capture_peer_cert_chain' => true,
1040 // 'SNI_enabled' => true, 1044 // 'SNI_enabled' => true,
@@ -172,6 +172,16 @@ class MailFun { @@ -172,6 +172,16 @@ class MailFun {
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
  175 + // 是否验证证书
  176 + if(in_array(parse_url($smtp['host'])['host']??'1-1',['mail.laser-tech.com.cn'])){
  177 + $mail->SMTPOptions = [
  178 + 'ssl' => [
  179 + 'verify_peer' => false, // 有的证书和域名不匹配,这里关闭认证
  180 + 'verify_peer_name' => false,// 有的证书和域名不匹配,这里关闭认证
  181 + ]
  182 + ];
  183 + }
  184 +
175 //Recipients,设置发件人 185 //Recipients,设置发件人
176 $mail->setFrom($email['email'], $data['nickname']??'');// 显示邮件来自谁 186 $mail->setFrom($email['email'], $data['nickname']??'');// 显示邮件来自谁
177 // //设置收件人 187 // //设置收件人
@@ -280,6 +290,16 @@ class MailFun { @@ -280,6 +290,16 @@ class MailFun {
280 $mail->Port = $smtp['port']; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` 290 $mail->Port = $smtp['port']; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
281 $mail->CharSet = 'utf-8'; 291 $mail->CharSet = 'utf-8';
282 $mail->Encoding = PHPMailer::ENCODING_QUOTED_PRINTABLE; 292 $mail->Encoding = PHPMailer::ENCODING_QUOTED_PRINTABLE;
  293 + // 是否验证证书
  294 + if(in_array(parse_url($smtp['host'])['host']??'1-1',['mail.laser-tech.com.cn'])){
  295 + $mail->SMTPOptions = [
  296 + 'ssl' => [
  297 + 'verify_peer' => false, // 有的证书和域名不匹配,这里关闭认证
  298 + 'verify_peer_name' => false,// 有的证书和域名不匹配,这里关闭认证
  299 + ]
  300 + ];
  301 + }
  302 +
283 303
284 try { 304 try {
285 return $mail->smtpConnect(); 305 return $mail->smtpConnect();