contact: exceptional parsing and delivery for bbq
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 7 Aug 2018 14:09:16 +0000 (16:09 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 7 Aug 2018 14:21:33 +0000 (16:21 +0200)
contact.php

index 94d8ebe04ad680832175b4eb96f1eda275188840..c55ec0c033081af57341d891810722feb10aa547 100644 (file)
@@ -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 <heleen.terlouw.2910@gmail.com>';
+               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(