From 42b9b3a62eeca1e600e5a8a71490c80177df88ed Mon Sep 17 00:00:00 2001 From: Brain Date: Wed, 24 Aug 2022 14:35:01 +0200 Subject: [PATCH] Set the return path via the envelope sender --- assets/php/contact_form.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/assets/php/contact_form.php b/assets/php/contact_form.php index 9b2c73c..d6b93a6 100644 --- a/assets/php/contact_form.php +++ b/assets/php/contact_form.php @@ -34,17 +34,25 @@ function prepare_message_body(string $message, string $name) { * phpmailer: Bibliothek, der per Composer installiert wird. Tut ganz gut mit SMTP. */ function send_message_to_office(string $subject, string $message, string $name, string $email) { + $returnPath = filter_var(getenv('WTF_RETURN_PATH'), FILTER_VALIDATE_EMAIL); + $to = filter_var(getenv('WTF_CONTACT_TO'), FILTER_VALIDATE_EMAIL); + + if (!$returnPath || !$to) { + error_log('Address for "To" or "Return-Path" is invalid'); + return false; + } + return mail( - getenv('WTF_CONTACT_TO'), + $to, "=?UTF-8?B?" . base64_encode($subject) . "?=", prepare_message_body($message, $name), - $additional_headers = array( + array( "From" => getenv('WTF_CONTACT_FROM'), "Reply-To" => $email, - "Return-Path" => getenv('WTF_RETURN_PATH'), "Content-Type" => "text/plain; charset=utf-8", "Content-Transfer-Encoding" => "base64", ), + "-f $returnPath" ); }