mail = new PHPMailer(true); $this->mail->CharSet = 'UTF-8'; $this->mail->isSMTP(); $this->mail->SMTPAuth = true; $this->mail->SMTPDebug = 0; $this->mail->Host = $config['host'] ?? ''; $this->mail->Port = $config['port'] ?? 587; $this->mail->Username = $config['username'] ?? ''; $this->mail->Password = $config['password'] ?? ''; } /** * @throws Exception */ public function send(string $address): void { $this->mail->setFrom($this->mail->Username, $this->mail->Host); $this->mail->addAddress($address); $this->mail->Subject = 'Код подтверждения'; $body = '
«Hello, world!»
'; $this->mail->msgHTML($body); $this->mail->send(); } }