Set the return path via the envelope sender
All checks were successful
continuous-integration/drone/pr Build is passing

This commit is contained in:
Brain 2022-08-24 14:35:01 +02:00
parent 590cbfbb65
commit 42b9b3a62e
Signed by: Brain
GPG Key ID: 9CF47083EE57670D

View File

@ -34,17 +34,25 @@ function prepare_message_body(string $message, string $name) {
* phpmailer: Bibliothek, der per Composer installiert wird. Tut ganz gut mit SMTP. * 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) { 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( return mail(
getenv('WTF_CONTACT_TO'), $to,
"=?UTF-8?B?" . base64_encode($subject) . "?=", "=?UTF-8?B?" . base64_encode($subject) . "?=",
prepare_message_body($message, $name), prepare_message_body($message, $name),
$additional_headers = array( array(
"From" => getenv('WTF_CONTACT_FROM'), "From" => getenv('WTF_CONTACT_FROM'),
"Reply-To" => $email, "Reply-To" => $email,
"Return-Path" => getenv('WTF_RETURN_PATH'),
"Content-Type" => "text/plain; charset=utf-8", "Content-Type" => "text/plain; charset=utf-8",
"Content-Transfer-Encoding" => "base64", "Content-Transfer-Encoding" => "base64",
), ),
"-f $returnPath"
); );
} }