use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
class TMail {
public static function SendMail($to,$title,$body){
global $db;
$answer=AnswerStruc(true,"Не удалось отправить почту");
$mail = new PHPMailer(true);
$mail->SMTPDebug = SMTP::DEBUG_SERVER;
$mail->isSMTP();
$mail->Host = TConfig::GetConfigKeyValue("mail_server");
$mail->SMTPAuth = true;
$mail->Username = TConfig::GetConfigKeyValue("mail_server_login");
$mail->Password = TConfig::GetConfigKeyValue("mail_server_password");
//$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->CharSet = 'UTF-8';
$mail->Encoding = 'base64';
$mail->Port = TConfig::GetConfigKeyValue("smtp_port");
$mail->SMTPAuth = true;
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->setFrom(TConfig::GetConfigKeyValue("mail_server_sender"));
$mail->addAddress($to);
$mail->isHTML(true);
$mail->Subject = $title;
$mail->Body = $body;
if (!$mail->send()) {
$answer=AnswerStruc(true,$mail->ErrorInfo);
} else {
$answer=AnswerStruc(false,"Ok");
}
return $answer;
}
}