Merge branch 'contactform' into staging
All checks were successful
Deploy Hugo / deploy (push) Successful in 39s

This commit is contained in:
Jens M. Sauer 2024-10-24 12:21:34 +02:00
commit af701086bf

View File

@ -6,35 +6,36 @@ require 'PHPMailer/src/SMTP.php';
use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception; use PHPMailer\PHPMailer\Exception;
// Lade die Konfigurationsdatei
$config = require '/var/www/vhosts/hosting205886.ae948.netcup.net/bar-filipo.de/credentials/config.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = htmlspecialchars($_POST['name']); $name = htmlspecialchars($_POST['name']);
$email = htmlspecialchars($_POST['email']); $email = htmlspecialchars($_POST['email']);
$message = htmlspecialchars($_POST['message']); $message = htmlspecialchars($_POST['message']);
$config = parse_ini_file('/var/www/vhosts/hosting205886.ae948.netcup.net/bar-filipo.de/credentials/config.ini', true);
$mail = new PHPMailer(true); $mail = new PHPMailer(true);
try { try {
// SMTP-Einstellungen aus der Konfigurationsdatei laden // SMTP-Einstellungen aus der Konfigurationsdatei laden
$mail->isSMTP(); $mail->isSMTP();
$mail->Host = $config['smtp_host']; $mail->SMTPDebug = 2;
$mail->SMTPAuth = true; $mail->Debugoutput = 'echo';
$mail->Username = $config['smtp_username']; $mail->Host = $config['smtp']['host'];
$mail->Password = $config['smtp_password']; $mail->SMTPAuth = true;
$mail->SMTPSecure = $config['smtp_encryption']; $mail->Username = $config['smtp']['username'];
$mail->Port = $config['smtp_port']; $mail->Password = $config['smtp']['password'];
$mail->SMTPAutoTLS = true;
$mail->Port = $config['smtp']['port'];
// E-Mail-Einstellungen // E-Mail-Einstellungen
$mail->setFrom($config['smtp_username'], 'Formular-Betreiber'); $mail->setFrom($config['smtp']['username'], 'Formular-Betreiber');
$mail->addAddress($config['recipient']); $mail->addAddress($config['smtp']['recipient']);
$mail->isHTML(true); $mail->isHTML(true);
$mail->Subject = 'Neue Nachricht vom Kontaktformular'; $mail->Subject = 'Neue Nachricht vom Kontaktformular';
$mail->Body = "Name: $name<br>E-Mail: $email<br>Nachricht: $message"; $mail->Body = "Name: $name<br>E-Mail: $email<br>Nachricht: $message";
$mail->AltBody = "Name: $name\nE-Mail: $email\nNachricht: $message"; $mail->AltBody = "Name: $name\nE-Mail: $email\nNachricht: $message";
print_r($config);
$mail->send(); $mail->send();
echo 'Nachricht wurde erfolgreich gesendet.'; echo 'Nachricht wurde erfolgreich gesendet.';
} catch (Exception $e) { } catch (Exception $e) {