Files
anpdf/app/routes/sendmail.php
2021-06-21 18:30:01 +03:00

80 lines
2.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
function testmail_kuri(){
// echo klanmail('ak@argumenti.ru', 'тестовое письмо', 'Это тестовое письмо о заказах', set('klanmail'));
}
function klanmail( $mail, $subject, $message, $frommail ) {
$mail = mb_strtolower($mail);
if (isset($frommail['login']) and $frommail['login'] !== '')
$login = $frommail['login'];
else {
$login = $frommail['mail'];
}
$send = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$send->isSMTP();
//$send->SMTPDebug=3; // Set mailer to use SMTP
$send->Host = $frommail['host']; // Specify main and backup SMTP servers
// Enable SMTP authentication
$send->Username = $login; // SMTP username
$send->Password = $frommail['password'];
if (isset($frommail['secure'])) {
$send->SMTPSecure = $frommail['secure'];
$send->SMTPAuth = true;
}
else {
$mail->SMTPSecure = false;
$mail->SMTPAutoTLS = false;
}
$send->Port = $frommail['port']; // TCP port to connect to
$send->setFrom($frommail['mail'], 'Аргументы Недели');
$send->addAddress($mail, $mail); // Add a recipient
$send->CharSet = 'UTF-8';
$send->isHTML(True); // Set email format to HTML
$send->Subject = $subject;
/*ob_start();
include 'mail.phtml';
$mailbody = ob_get_contents();
ob_end_clean();*/
$send->Body = $message;
//$headers = "MIME-Version: 1.0\r\n";
//$headers .= "Content-type: text/plain; charset=utf-8\r\n";
//$headers .= "Content-Transfer-Encoding: 8bit \r\n";
//$headers .= "From: nomer@arguments.ru\r\n";
//$headers .= 'Reply-To: nomer@arguments.ru'."\r\n";
//if (mail($mail, $subject, $message, $headers))
// $status = 'OK';
//else
// $status = 'NO';
if($send->send())
$status = 'OK';
else {
$status = 'NO';
echo 'Mailer Error: ' . $send->ErrorInfo."\n";
}
return $status;
}