Skip to content

Commit

Permalink
add safegaurd and additional logging
Browse files Browse the repository at this point in the history
Issue #10
  • Loading branch information
kruisdraad committed Feb 24, 2015
1 parent eb45f73 commit 85c82c7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions libexec/mda
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if ($parser_func($message)) {
}

function bounce($message) {
logger(LOG_WARNING, "Bouncing message to admin because i was unabled to parse it");
logger(LOG_WARNING, "Attempting to bounce message to admin because i was unabled to parse it");

$tempfile = "/tmp/" . mt_rand();
file_put_contents($tempfile, $message['raw']);
Expand All @@ -73,9 +73,15 @@ function bounce($message) {

$email->AddAttachment( $tempfile , 'bounce.eml' );

$email->Send();
if(!$email->Send()) {
logger(LOG_ERR, "Bouncing to " . FALLBACK_MAIL . " failed.");
exit(1);

exit(0);
} else {
logger(LOG_WARNING, "Bounced to " . FALLBACK_MAIL . " successfully.");
exit(0);

}
}

?>

0 comments on commit 85c82c7

Please sign in to comment.