Files
anpdf/app/routes/email.php

34 lines
1003 B
PHP
Raw Normal View History

2020-07-02 17:27:30 +03:00
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
function sendmail($config, $mail){
$send = new PHPMailer;
$send->isSMTP();
//$send->SMTPDebug=3; // Set mailer to use SMTP
$send->Host = $config['host']; // Specify main and backup SMTP servers
$send->Username = $config['login']; // SMTP username
$send->Password = $config['password'];
if (isset($frommail['secure'])) {
$send->SMTPSecure = $frommail['secure'];
$send->SMTPAuth = true;
}
else {
$mail->SMTPSecure = false;
$mail->SMTPAutoTLS = false;
}
$send->Port = $config['port']; // TCP port to connect to
$send->setFrom($config['mail'], $config['name']);
$send->addAddress($mail, $mail); // Add a recipient
$send->CharSet = 'UTF-8';
$send->isHTML(True); // Set email format to HTML
$send->Subject = $mail['subject'];
$send->Body = $mail['message'];
return $send->send();
}