diff --git a/redirect.php b/redirect.php index ab116af..0cd5667 100755 --- a/redirect.php +++ b/redirect.php @@ -13,6 +13,11 @@ $debugMode = getenv('DEBUG_MODE'); // Dry Run Mode will suppress sending an e-mail to Redmine. Only really useful with debug mode on. $dryRun = getenv('DRY_RUN'); +// Test addresses work normally, but tag the email subject with "[TEST]". +$test = getenv('TEST'); + +$deliveryAddress = getenv('DELIVERY_ADDRESS'); + if($debugMode) { error_reporting(E_ALL); } @@ -41,7 +46,7 @@ while (!feof($fd)) { //if this line is the "delivered-to", extract the subaddress, if there is one. if(preg_match("/^delivered-to: (.*)/i", $line, $matches)) { $deliveredTo = $matches[1]; - if(preg_match("/support_mt.*\+(\S*)@/i", $deliveredTo, $matches)) { + if(preg_match("/$deliveryAddress.*\+(\S*)@/i", $deliveredTo, $matches)) { $project = $matches[1]; } } @@ -52,9 +57,7 @@ while (!feof($fd)) { } //Alter the Subject if this is a test. - $subjectAlterTo = substr($deliveredTo, 1, 12); - if(substr($deliveredTo, 1, 15) == 'support_mt_test' && - preg_match("/^Subject:(.*)/i", $line)) { + if ($test && preg_match("/^Subject:(.*)/i", $line)) { $line = $subject = str_replace('Subject: ', 'Subject: [TEST] ', $line); }