contact: strip www. subdomain from mail address
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 9 Jan 2019 00:14:28 +0000 (01:14 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Sun, 10 Feb 2019 08:21:22 +0000 (09:21 +0100)
Fix invalid recipient info@www.domain.tld for non-redirecting domains.

Reported-by: Arie van Marion
contact.php

index 9d0b1bcae9d16f15968dccf7621dd77237c058e4..7ffa40926f520546ec9567c99705b94a91800800 100644 (file)
@@ -14,7 +14,8 @@ if ($_POST) {
 function mailform($input = [])
 {
        $source = empty($input['subject']) ? 'reactie' : $input['subject'];
 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) {
        $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'])
 }
 
        $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(
        $header = "From: $reply";
 
        foreach (array(