Created
July 24, 2018 12:18
-
-
Save lcdservices/ce1f90cf18c42f44c0648acc3de5a58d to your computer and use it in GitHub Desktop.
ODE From Email whitelisting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/media/civicrm/ext/biz.jmaconsulting.ode/ode.php b/media/civicrm/ext/biz.jmaconsulting.ode/ode.php | |
index 2f02955..a8ce61b 100644 | |
--- a/media/civicrm/ext/biz.jmaconsulting.ode/ode.php | |
+++ b/media/civicrm/ext/biz.jmaconsulting.ode/ode.php | |
@@ -165,6 +165,11 @@ function toCheckEmail($email, $field, $returnHostName = FALSE) { | |
return $host; | |
} | |
+ //LCD check FROM email addresses | |
+ if (isFromEmail($email)) { | |
+ return $error; | |
+ } | |
+ | |
$hostLength = strlen($host); | |
if (substr($email, -$hostLength) != $host) { | |
$error[$field] = ts('The Outbound Domain Enforcement extension has prevented this From Email Address from being used as it uses a different domain than the System-generated Mail Settings From Email Address configured at Administer > Communications > Organization Address and Contact Info.'); | |
@@ -591,3 +596,24 @@ function ode_civicrm_apiWrappers(&$wrappers, $apiRequest) { | |
} | |
} | |
} | |
+ | |
+/** | |
+ * //LCD | |
+ * @param $email | |
+ * | |
+ * @return bool | |
+ * | |
+ * check if passed email is in list of configured FROM email addresses | |
+ * return TRUE if so | |
+ */ | |
+function isFromEmail($email) { | |
+ $domainEmails = CRM_Core_BAO_Email::domainEmails(); | |
+ | |
+ foreach ($domainEmails as $domainEmail => $dontCare) { | |
+ if (strpos($domainEmail, "<{$email}>") !== FALSE) { | |
+ return TRUE; | |
+ } | |
+ } | |
+ | |
+ return FALSE; | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment