contact: save email contents to log file
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 8 Jan 2019 23:32:17 +0000 (00:32 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 26 Jan 2021 01:15:15 +0000 (02:15 +0100)
Backup in case of undelivered or otherwise lost messages.

widget/contact.php

index de059ec4a2405ac46ebc5ca0f35e5a60f74a6233..8fdc948f21a76af8b02f0038e51af47c8cb88dc8 100644 (file)
@@ -79,6 +79,12 @@ switch ($source) {
                $body .= "$k: $v\r\n";
        }
 
+       if ($logfile = fopen('maillog.txt', 'a')) {
+               $logdata = "Date: ".strftime("%F %T");
+               $logdata .= "\nTo: $rcpt\nSubject: $subject\n$header\n\n$body.\n\n";
+               fwrite($logfile, str_replace("\r\n", "\n", $logdata));
+       }
+
        $sent = mail($rcpt, $subject, $body, $header);
        if (!$sent)
                return 'Helaas ging er iets mis bij het doorvoeren. Probeer het later nog eens.';