mail send upgrade

This commit is contained in:
sHa
2019-10-07 23:18:20 +03:00
parent b2f0562603
commit bb3fbc62d2
11 changed files with 1311 additions and 1761 deletions

44
sender.php Normal file
View File

@@ -0,0 +1,44 @@
<?php
require __DIR__.'/vendor/autoload.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
class sender
{
public function send($data)
{
$dotenv = \Dotenv\Dotenv::create(__DIR__);
$dotenv->load();
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->CharSet = 'UTF-8';
$mail->Host = getenv('SMTP_SERVER');
$mail->SMTPAuth = true;
$mail->Username = getenv('SMTP_USER');
$mail->Password = getenv('SMTP_PASSWORD');
$mail->SMTPSecure = 'tls';
$mail->From = getenv('SENDER_EMAIL');
$mail->FromName = getenv('SENDER_NAME');
$mail->addAddress(getenv('SMTP_RECEIVER'));
$mail->isHTML(true);
$mail->Subject = $data->subject;
$mail->Body = $data->body;
$mail->send();
echo 'Message has been sent';
return true;
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
return false;
}
}
}