From d318c99ba522f2450d65142c47bae2c5c05eaec4 Mon Sep 17 00:00:00 2001 From: stasbilay02 Date: Wed, 4 Dec 2024 16:37:11 +0300 Subject: [PATCH] SMTP --- kernel/helpers/SMTP.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/kernel/helpers/SMTP.php b/kernel/helpers/SMTP.php index 4ca2f46..9abdf95 100644 --- a/kernel/helpers/SMTP.php +++ b/kernel/helpers/SMTP.php @@ -8,21 +8,17 @@ use PHPMailer\PHPMailer\PHPMailer; class SMTP { public PHPMailer $mail; - public string $host; - public int $port; - public string $username; - public string $password; - public function __construct(array $config = []) { $this->mail = new PHPMailer(true); + $this->mail->CharSet = 'UTF-8'; $this->mail->isSMTP(); $this->mail->SMTPAuth = true; $this->mail->SMTPDebug = 0; - $this->host = $config['host'] ?? ''; - $this->port = $config['port'] ?? 587; - $this->username = $config['username'] ?? ''; - $this->password = $config['password'] ?? ''; + $this->mail->Host = $config['host'] ?? ''; + $this->mail->Port = $config['port'] ?? 587; + $this->mail->Username = $config['username'] ?? ''; + $this->mail->Password = $config['password'] ?? ''; } /** @@ -30,7 +26,7 @@ class SMTP */ public function send(string $address): void { - $this->mail->setFrom($this->username, $this->host); + $this->mail->setFrom($this->mail->Username, $this->mail->Host); $this->mail->addAddress($address); $this->mail->Subject = 'Код подтверждения'; $body = '

«Hello, world!»

';