SMTP
This commit is contained in:
parent
15c801f579
commit
d318c99ba5
@ -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 = '<p><strong>«Hello, world!» </strong></p>';
|
||||
|
Loading…
Reference in New Issue
Block a user