teacher
This commit is contained in:
@@ -12,16 +12,24 @@ $dotenv->load();
|
||||
|
||||
function sendEmail($to, $subject, $body, $attachments = [], $cc = [], $bcc = [])
|
||||
{
|
||||
|
||||
// Configurazione SMTP
|
||||
$mail = new PHPMailer(true);
|
||||
try {
|
||||
|
||||
// Configurazione server SMTP con dati da .env
|
||||
$mail->isSMTP();
|
||||
$mail->Host = $_ENV['MAIL_HOST'] ?? 'smtp.example.com';
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = $_ENV['MAIL_USERNAME'] ?? 'email@example.com';
|
||||
$mail->Password = $_ENV['MAIL_PASSWORD'] ?? 'password';
|
||||
$mail->SMTPSecure = $_ENV['MAIL_ENCRYPTION'] ?? PHPMailer::ENCRYPTION_STARTTLS;
|
||||
$enc = strtolower(trim($_ENV['MAIL_ENCRYPTION'] ?? 'tls'));
|
||||
if ($enc === 'ssl') {
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
|
||||
} else {
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
}
|
||||
|
||||
$mail->Port = $_ENV['MAIL_PORT'] ?? 587;
|
||||
|
||||
// Mittente
|
||||
|
||||
Reference in New Issue
Block a user