From 6cd8dc5d7de3648d46545d68d5f76735b91be143 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Tue, 7 Aug 2018 16:09:16 +0200 Subject: [PATCH] contact: exceptional parsing and delivery for bbq --- contact.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/contact.php b/contact.php index 94d8ebe..c55ec0c 100644 --- a/contact.php +++ b/contact.php @@ -13,10 +13,21 @@ if ($_POST) { function mailform($input = []) { $source = empty($input['subject']) ? 'reactie' : $input['subject']; + $rcpt = 'info@'.$_SERVER['HTTP_HOST']; + $subject = "Formulier {$_SERVER['HTTP_HOST']}: $source"; + if (!$input) { return 'Geen gegevens ontvangen. Probeer het nog eens.'; } -if ($source != 'bbq') { + +switch ($source) { + case 'bbq': + if (empty($input['naam']) or empty($input['huis'])) { + return 'De bedoeling is juist dat je opgeeft wie er komt.'; + } + $rcpt .= ', Heleen '; + break; + default: if (empty($input['email']) or !preg_match('/.+@.+\..+/', $input['email'])) { return 'Een geldig e-mailadres is verplicht zodat we antwoord kunnen geven.'; } @@ -25,10 +36,8 @@ if ($source != 'bbq') { } } - $rcpt = 'info@'.$_SERVER['HTTP_HOST']; - $subject = "Formulier {$_SERVER['HTTP_HOST']}: $source"; $reply = preg_match('/\A\w+@\w+\.[a-z]+\z/', @$input['email']) - ? $input['email'] : $rcpt; + ? $input['email'] : 'noreply@'.$_SERVER['HTTP_HOST']; $header = "From: $reply"; foreach (array( -- 2.30.0