Abstract save email function; call the function on routing error

This commit is contained in:
Jon Goldberg 2018-01-24 15:14:33 -05:00
parent 0c9d808302
commit 281022be8f

View File

@ -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;
}
?>