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" ); }