Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lcdservices/ce1f90cf18c42f44c0648acc3de5a58d to your computer and use it in GitHub Desktop.
Save lcdservices/ce1f90cf18c42f44c0648acc3de5a58d to your computer and use it in GitHub Desktop.
ODE From Email whitelisting
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