SendMail调试完成

This commit is contained in:
筱锋xiao_lfeng 2023-05-05 16:33:40 +08:00
parent fbae80215e
commit 0fec3b0ad2

View File

@ -18,10 +18,11 @@ class SendMail
public static int $EmailType; public static int $EmailType;
public static string $EmailReceiver; public static string $EmailReceiver;
private static array $ConfigData; protected static array $ConfigData;
public static int $ExpTime; public static int $ExpTime;
public static string $WebTitle; public static string $WebTitle;
protected PHPMailer $Mail; protected PHPMailer $Mail;
public static string $SendMailError;
/** /**
* @return void 导入文件,无具体返回值 * @return void 导入文件,无具体返回值
@ -52,7 +53,7 @@ public function __construct()
private function SSLCheck(string $Smtp_Type) private function SSLCheck(string $Smtp_Type)
{ {
if ($Smtp_Type == 'Port') if ($Smtp_Type == 'Port')
return $_SERVER['SERVER_PORT'] != '443' ? $this->ConfigData['Port'] : $this->ConfigData['SecurePort']; return $_SERVER['SERVER_PORT'] != '443' ? self::$ConfigData['Port'] : self::$ConfigData['SecurePort'];
elseif ($Smtp_Type == 'Secure') elseif ($Smtp_Type == 'Secure')
if ($_SERVER['SERVER_PORT'] != '443') if ($_SERVER['SERVER_PORT'] != '443')
return 'TLS'; return 'TLS';
@ -93,6 +94,7 @@ public function PostMail(string $EmailReceiver, int $EmailType, string $OtherPus
$this->Mail->Port = $this->SSLCheck('Port'); $this->Mail->Port = $this->SSLCheck('Port');
$this->Mail->setFrom(self::$ConfigData['User'], self::$ConfigData['Name']); $this->Mail->setFrom(self::$ConfigData['User'], self::$ConfigData['Name']);
$this->Mail->addAddress($EmailReceiver); $this->Mail->addAddress($EmailReceiver);
$this->Mail->isHTML(true);
// 发件编写 // 发件编写
if ($EmailType == 1) $this->EmailRegister(); if ($EmailType == 1) $this->EmailRegister();
@ -100,8 +102,8 @@ public function PostMail(string $EmailReceiver, int $EmailType, string $OtherPus
$this->Mail->send(); $this->Mail->send();
return true; return true;
} catch (Exception $e) { } catch (\Exception $e) {
//echo '邮件发送失败:', $this->$this->Mail->ErrorInfo; self::$SendMailError = $this->Mail->ErrorInfo;
return false; return false;
} }
} }