From: Mischa POSLAWSKY Date: Wed, 9 Jan 2019 00:14:28 +0000 (+0100) Subject: contact: strip www. subdomain from mail address X-Git-Tag: v3.9~19 X-Git-Url: http://git.shiar.nl/minimedit.git/commitdiff_plain/db8b9e671cfa5dcb27548dde4f8603a37d33122f contact: strip www. subdomain from mail address Fix invalid recipient info@www.domain.tld for non-redirecting domains. Reported-by: Arie van Marion --- 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(