From 281022be8f1371b9f1a45265d8a798f170934ba5 Mon Sep 17 00:00:00 2001 From: Jon Goldberg Date: Wed, 24 Jan 2018 15:14:33 -0500 Subject: [PATCH] Abstract save email function; call the function on routing error --- redirect.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/redirect.php b/redirect.php index 5206679..574284d 100755 --- a/redirect.php +++ b/redirect.php @@ -87,20 +87,14 @@ if($project) { } if($debugMode) { - // debug code + //debug code. $email .= "\n\nDelivered To - $deliveredTo\n"; $email .= "Project - $project\n"; $email .= "From - $from\n"; $email .= "Subject - $subject\n"; $email .= "Params:\n"; $email .= print_r($params, TRUE); - $debugFileName = '/tmp/EmailProcessing' . time(); - echo "$debugFileName"; - $debugFile = fopen($debugFileName, 'w'); - fwrite($debugFile, $email); - fclose($debugFile); - // also print to stdout, in case we're running manually - echo $email; + saveEmail($email); } if(!$dryRun) { @@ -146,6 +140,7 @@ function SendToMailHandler($input, $params) { $message = $log . "\n\n"; $message .= $input; mail($to, $subject, $message); + saveEmail($input); } echo "command returned $return_value\n"; @@ -186,4 +181,14 @@ function ParseSenderDomain($email) { return $project; } +function saveEmail($email) { + $debugFileName = '/tmp/EmailProcessing' . time(); + echo "$debugFileName"; + $debugFile = fopen($debugFileName, 'w'); + fwrite($debugFile, $email); + fclose($debugFile); + // also print to stdout, in case we're running manually + echo $email; +} + ?>