33 lines
864 B
PHP
Executable File
33 lines
864 B
PHP
Executable File
<?php
|
|
use PHPMailer\PHPMailer\PHPMailer;
|
|
use PHPMailer\PHPMailer\Exception;
|
|
|
|
require __DIR__ . '/vendor/autoload.php';
|
|
require __DIR__ . '/smtp_config.php';
|
|
|
|
function sendEmail($to, $subject, $body){
|
|
$mail = new PHPMailer(true);
|
|
try {
|
|
$mail->isSMTP();
|
|
$mail->Host = SMTP_HOST;
|
|
$mail->SMTPAuth = true;
|
|
$mail->Username = SMTP_USER;
|
|
$mail->Password = SMTP_PASS;
|
|
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // TLS
|
|
$mail->Port = SMTP_PORT;
|
|
|
|
$mail->setFrom(SMTP_FROM, SMTP_FROM_NAME);
|
|
$mail->addAddress($to);
|
|
|
|
$mail->isHTML(true);
|
|
$mail->Subject = $subject;
|
|
$mail->Body = $body;
|
|
|
|
$mail->send();
|
|
return true;
|
|
} catch (Exception $e) {
|
|
error_log("Mailer Error: ".$mail->ErrorInfo);
|
|
return false;
|
|
}
|
|
}
|