I'm successfully using the Autofiling email activities via EmailProcessor feature for Individuals.

However, when I try to automatically associate to an Organization with an email address the email is not attached as an activity. Instead CiviCRM creates a NEW Individual with the email contents attached as an Activity.

Is there a way to have CiviCRM's Email Processor look at Individuals AND Organizations for the Autofiling of email activities?


There's a way to do it by implementing a PHP override or (not advised) hacking CiviCRM core.

The logic behind only filing emails on individuals is that organizations don't actually send emails. That said - you surely know your needs better than I do.

The file in question is <civiroot>/CRM/Utils/Mail/Incoming.php. Around line 461 is a function called getContactID. Change line 462 from this:

$dao = CRM_Contact_BAO_Contact::matchContactOnEmail($email, 'Individual');

to this:

$dao = CRM_Contact_BAO_Contact::matchContactOnEmail($email);

If you hack core directly, you'll have to make this change every time you upgrade. You can also do a PHP override, which is somewhat better - but you'll still need to occasionally compare the file to see if any other changes have crept in.

  • Thanks for the very clear instructions. I was looking for a UI/Admin-level solution, rather than a source code solution, but if things get dire I'll take these steps or get some developer time. – Elijah van der Giessen Sep 5 '17 at 19:56

Jon's answer should work but also adding that you could use hook_emailProcessorContact (https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_emailProcessorContact/)

There is an example of how to use it in here: https://github.com/civicrm/civicrm-drupal/blob/7.x-master/civitest.module.sample

The way it's used in that sample is intended to allow you to tag contacts so that you could have either a "domain" org contact for a given domain (i.e. say you have an org who's email is info@xyz.com, then all emails from @xyz.com get filed on that org), or a "catch-all" contact for a given domain (i.e. if the email matches an individual then file it there, otherwise file it on the tagged org).

But it could be modified slightly to meet your need and just always override if an org contact with the given email exists.

  • Thanks! Good to know the thinking of the CiviCRM team. I use "alias" email addresses to address regional groups of volunteers, but I get that it's an unusual use case. – Elijah van der Giessen Sep 5 '17 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.