getRow ( 'SELECT host, port, secure, sender, sender_name, user, password FROM mail_config' ); $mail = new \PHPMailer (); $mail->isSMTP (); $mail->Host = $conf['host']; if (!empty ($conf['user'])) { $mail->SMTPAuth = TRUE; $mail->Username = $conf['user']; $mail->Password = base64_decode ($conf['password']); } else $mail->SMTPAuth = FALSE; if ($conf['secure']) { $mail->SMTPSecure = 'ssl'; $mail->Port = 465; } $mail->setFrom ($conf['sender'], $conf['sender_name']); $mail->AddAddress ($mailTo); $mail->IsHTML (TRUE); $mail->Subject = $subject; $mail->Body = $body; $mail->CharSet = 'UTF-8'; if (!$mail->Send ()) throw new UserException ('Send error: '.$mail->ErrorInfo); } }