Files
anpdf/app/routes/sendmail.php

79 lines
2.1 KiB
PHP
Raw Permalink Normal View History

2021-06-21 17:55:53 +03:00
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
function testmail_kuri(){
2021-06-21 18:30:01 +03:00
// echo klanmail('ak@argumenti.ru', 'тестовое письмо', 'Это тестовое письмо о заказах', set('klanmail'));
2021-06-21 17:55:53 +03:00
}
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())
2021-06-21 22:31:49 +03:00
$status = true;
2021-06-21 17:55:53 +03:00
else {
2021-06-21 22:31:49 +03:00
$status = 'Mailer Error: ' . $send->ErrorInfo."\n";
2021-06-21 17:55:53 +03:00
}
return $status;
}