Initial commit: struttura base Diplomacy Web App con header/footer e auth
This commit is contained in:
32
send_email.php
Executable file
32
send_email.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user