2020-07-02 17:27:30 +03:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
use PHPMailer\PHPMailer\PHPMailer;
|
|
|
|
|
|
use PHPMailer\PHPMailer\Exception;
|
|
|
|
|
|
|
2025-03-11 22:04:36 +03:00
|
|
|
|
|
|
|
|
|
|
function sendmail($config, $mail) {
|
|
|
|
|
|
ini_set('display_errors', 1);
|
|
|
|
|
|
ini_set('display_startup_errors', 1);
|
|
|
|
|
|
error_reporting(E_ALL);
|
|
|
|
|
|
|
|
|
|
|
|
$send = new PHPMailer(true);
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
//$send->SMTPDebug = 2; // Включить отладку
|
|
|
|
|
|
//$send->Debugoutput = 'html';
|
|
|
|
|
|
|
|
|
|
|
|
$send->isSMTP();
|
|
|
|
|
|
$send->Host = 'mail.argumenti.ru';
|
|
|
|
|
|
$send->SMTPAuth = true;
|
|
|
|
|
|
$send->CharSet = 'UTF-8';
|
|
|
|
|
|
$send->Username = 'klan@mail.argumenti.ru';
|
|
|
|
|
|
$send->Password = 'Adfhj789-jkhgk6F';
|
|
|
|
|
|
$send->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
|
|
|
|
|
$send->Port = 587;
|
|
|
|
|
|
|
|
|
|
|
|
$send->setFrom('klan@mail.argumenti.ru', 'Аргументы Недели');
|
|
|
|
|
|
$send->addAddress($mail['mail'], $mail['mail']);
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($mail['html'])) {
|
|
|
|
|
|
$send->isHTML(true);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$send->ContentType = 'text/plain';
|
|
|
|
|
|
$send->isHTML(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$send->Subject = $mail['subject'];
|
|
|
|
|
|
$send->Body = $mail['message'];
|
|
|
|
|
|
|
|
|
|
|
|
return $send->send();
|
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
|
//echo "Ошибка отправки: {$e->getMessage()}";
|
|
|
|
|
|
echo '<p>К сожалению в данный момент письмо невозможно отправить.</p><p>Попробуйте позже.</p>';
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function sendmail_old($config, $mail){
|
2020-07-02 17:27:30 +03:00
|
|
|
|
|
|
|
|
|
|
$send = new PHPMailer;
|
|
|
|
|
|
$send->isSMTP();
|
2020-08-29 12:52:45 +03:00
|
|
|
|
//$send->SMTPDebug=3; // Set mailer to use SMTP
|
2020-07-02 17:27:30 +03:00
|
|
|
|
$send->Host = $config['host']; // Specify main and backup SMTP servers
|
|
|
|
|
|
$send->Username = $config['login']; // SMTP username
|
|
|
|
|
|
$send->Password = $config['password'];
|
|
|
|
|
|
|
2020-08-29 12:50:57 +03:00
|
|
|
|
if (isset($config['secure'])) {
|
|
|
|
|
|
$send->SMTPSecure = $config['secure'];
|
2020-07-02 17:27:30 +03:00
|
|
|
|
$send->SMTPAuth = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
2020-08-29 12:50:57 +03:00
|
|
|
|
$send->SMTPSecure = false;
|
|
|
|
|
|
$send->SMTPAutoTLS = false;
|
2020-07-02 17:27:30 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$send->Port = $config['port']; // TCP port to connect to
|
2020-08-29 12:50:57 +03:00
|
|
|
|
$send->setFrom($config['login'], $config['name']);
|
|
|
|
|
|
$send->addAddress($mail['mail'], $mail['mail']); // Add a recipient
|
2020-07-02 17:27:30 +03:00
|
|
|
|
$send->CharSet = 'UTF-8';
|
2020-08-29 12:50:57 +03:00
|
|
|
|
|
|
|
|
|
|
if (isset($mail['html'])){
|
|
|
|
|
|
$send->isHTML(True); // Set email format to HTML
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
$send->ContentType = 'text/plain';
|
|
|
|
|
|
$send->isHTML(False);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-07-02 17:27:30 +03:00
|
|
|
|
$send->Subject = $mail['subject'];
|
|
|
|
|
|
$send->Body = $mail['message'];
|
|
|
|
|
|
|
|
|
|
|
|
return $send->send();
|
|
|
|
|
|
|
2025-03-11 22:04:36 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|