The main event - incorporate domain/email lookups into redirect.php

This commit is contained in:
Jon Goldberg 2018-01-18 02:03:26 -05:00
parent cc5b34d0a8
commit b52f6e571e
1 changed files with 17 additions and 17 deletions

View File

@ -75,7 +75,7 @@ if($from == 'Google Calendar <calendar-notification@google.com>') {
// If we don't know the project yet, attempt to determine it from the complete email address.
if(!$project) {
$project = ParseSenderEmail($from);
$project = ParseSenderEmail($from);
}
// Still no project? Check the domain of the sender.
if(!$project) {
@ -155,35 +155,35 @@ function SendToMailHandler($input, $params) {
//See if this email address is associated with a particular project
function ParseSenderEmail($from) {
$filePath = getenv('FILEPATH');
$project = $email = NULL;
if(preg_match("/\b([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4})\b/i", $from, $matches)) {
$email = $matches[1];
}
switch($email) {
case "ezra.berkley.nepon@gmail.com ":
$project = "astraea";
break;
//the following emails will not go into Redmine, and will cause an NDR to go to the sender.
case "billing@linode.com":
echo "dying";
die;
if (($handle = fopen($filePath . "/" . "data/usermap.csv", 'r')) !== FALSE) {
while (($data = fgetcsv($handle, 1000)) !== FALSE) {
$users[$data[0]] = $data[1];
}
}
if ($users[$email]) {
$project = $users[$email];
}
return $project;
}
function ParseSenderDomain($email) {
$filePath = getenv('FILEPATH');
$domain = $project = NULL;
if(preg_match("/@(.*)\b/", $email, $matches)) {
$domain = $matches[1];
}
switch($domain) {
case "legalmomentum.org":
$project = "lm-tech";
break;
//put spam domain entries here
case "allverbia.xyz":
echo "dying";
die;
if (($handle = fopen($filePath . "/" . "data/domainmap.csv", 'r')) !== FALSE) {
while (($data = fgetcsv($handle, 1000)) !== FALSE) {
$domains[$data[0]] = $data[1];
}
}
if($domains[$domain]) {
$project = $domains[$domain];
}
return $project;
}