From db8b9e671cfa5dcb27548dde4f8603a37d33122f Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Wed, 9 Jan 2019 01:14:28 +0100 Subject: [PATCH] contact: strip www. subdomain from mail address Fix invalid recipient info@www.domain.tld for non-redirecting domains. Reported-by: Arie van Marion --- contact.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contact.php b/contact.php index 9d0b1bc..7ffa409 100644 --- a/contact.php +++ b/contact.php @@ -14,7 +14,8 @@ if ($_POST) { function mailform($input = []) { $source = empty($input['subject']) ? 'reactie' : $input['subject']; - $rcpt = 'info@'.$_SERVER['HTTP_HOST']; + $domain = preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']); + $rcpt = "info@$domain"; $subject = "Formulier {$_SERVER['HTTP_HOST']}: $source"; if (!$input) { @@ -46,7 +47,7 @@ switch ($source) { } $reply = preg_match('/\A\w+@\w+\.[a-z]+\z/', @$input['email']) - ? $input['email'] : 'noreply@'.$_SERVER['HTTP_HOST']; + ? $input['email'] : "noreply@$domain"; $header = "From: $reply"; foreach (array( -- 2.30.0