Answers.Body: <p>There's a way to do it by implementing a PHP override or (not advised) hacking CiviCRM core.</p>
  
  <p>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.</p>
  
  <p>The file in question is <code>&lt;civiroot&gt;/CRM/Utils/Mail/Incoming.php</code>.  Around line 461 is a function called <code>getContactID</code>.  Change line 462 from this:</p>
  
  <pre><code>$dao = CRM_Contact_BAO_Contact::matchContactOnEmail($email, 'Individual');
  </code></pre>
  
  <p>to this:</p>
  
  <pre><code>$dao = CRM_Contact_BAO_Contact::matchContactOnEmail($email);
  </code></pre>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-05T19:56:02.127Z
Answers.Text: 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.
Answers.UserDisplayName: Elijah van der Giessen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-01T01:24:49.033Z
Answers.LastActivityDate: 2017-09-01T01:24:49.033Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>Jon's answer should work but also adding that you could use hook_emailProcessorContact (<a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_emailProcessorContact/" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_emailProcessorContact/</a>)</p>
  
  <p>There is an example of how to use it in here:
  <a href="https://github.com/civicrm/civicrm-drupal/blob/7.x-master/civitest.module.sample" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-drupal/blob/7.x-master/civitest.module.sample</a></p>
  
  <p>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).</p>
  
  <p>But it could be modified slightly to meet your need and just always override if an org contact with the given email exists.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-05T19:55:42.347Z
Answers.Text: 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.
Answers.UserDisplayName: Elijah van der Giessen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-01T18:23:32.887Z
Answers.LastActivityDate: 2017-09-01T18:23:32.887Z
Answers.UserDisplayName: Demerit
Body: <p>I'm successfully using the Autofiling email activities via EmailProcessor feature for Individuals.</p>
  
  <p>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.</p>
  
  <p>Is there a way to have CiviCRM's Email Processor look at Individuals AND Organizations for the Autofiling of email activities?</p>
  
Tags: <activities>
Title: Autofiling email activities via EmailProcessor to ORGANIZATION
ThreadText: # Autofiling email activities via EmailProcessor to ORGANIZATION
  
  (Asked by: username_0 on 2017-08-31)
  
  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?
  
  **Tags:** activities
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-09-01. Score: 2
  
  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.
  
  > **Comments:**
  > **username_0**: 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.  
  
  ---
  
  ### Answer by username_2 on 2017-09-01. Score: 2
  
  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.
  
  > **Comments:**
  > **username_0**: 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.  
  
  ---
  
  