CharSet = "UTF-8"; $Mail->SMTPDebug = 0; $Mail->isSMTP(); $Mail->Host = $config['SMTP']['HOST']; $Mail->SMTPAuth = true; $Mail->Username = $config['SMTP']['USER']; $Mail->Password = $config['SMTP']['PASSWORD']; $Mail->SMTPSecure = $this->SSL_Check('secure'); $Mail->Port = $this->SSL_Check('port'); $Mail->setFrom('noreplay@x-lf.cn', '筱锋机器人'); $Mail->addAddress($email); $Mail->isHTML(true); $Mail->Subject = '筱锋工具箱 - '.$type; // 邮箱标题 $Mail->Body = $SendMail->Templates($type,$user); // 邮箱正文 $Mail->AltBody = '筱锋工具箱 - '.$type.':'.$email; // 不支持HTML显示内容 $Mail->send(); return true; } catch (Exception $e) { echo '邮件发送失败:', $Mail->ErrorInfo; return false; } } // 检查是否是SSL private function SSL_Check($type) { global $config; if ($type == 'port') { if ($_SERVER['SERVER_PORT'] != '443') { return $config['SMTP']['NOSSL']; } else { return $config['SMTP']['SSL']; } } elseif ($type == 'secure') { if ($_SERVER['SERVER_PORT'] != '443') { return 'TLS'; } else { return 'ssl'; } } else { return null; } } }