CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • Prevent autofiling incoming email > activity from creating new users?
Pages: [1]

Author Topic: Prevent autofiling incoming email > activity from creating new users?  (Read 976 times)

david.a.king

  • I’m new here
  • *
  • Posts: 25
  • Karma: 0
  • CiviCRM version: 3.4.5
  • CMS version: drupal 6.22
  • MySQL version: 5.2
  • PHP version: 5.3
Prevent autofiling incoming email > activity from creating new users?
March 30, 2012, 06:18:44 am
Hi,
I've got autofiling email to activity working nicely, but i'd prefer if it did not create new users if an email address is not already in the contacts database - i can't see any settings for that..

I notice in Utils/Mail/Incoming.php:

Code: [Select]
   /**
     * retrieve a contact ID and if not present
     * create one with this email
     */
    function getContactID( $email, $name = null, $create = true ) {
        require_once 'CRM/Contact/BAO/Contact.php';
        $dao = CRM_Contact_BAO_Contact::matchContactOnEmail( $email, 'Individual' );
        if ( $dao ) {
            return $dao->contact_id;
        }

        if ( ! $create ) {
            return null;
        }

        // contact does not exist, lets create it
        $params = array( 'contact_type'   => 'Individual',
                         'email-Primary'  => $email );

        require_once 'CRM/Utils/String.php';
        CRM_Utils_String::extractName( $name, $params );

        return CRM_Contact_BAO_Contact::createProfileContact( $params,
                                                              CRM_Core_DAO::$_nullArray );
    }

but not sure how to alter that and still have the rest working as normal.. any ideas?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Prevent autofiling incoming email > activity from creating new users?
March 30, 2012, 06:45:37 am

You can do this via a hook as documented in this issue here:

http://issues.civicrm.org/jira/browse/CRM-8978

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Tiffani Chin

  • I post occasionally
  • **
  • Posts: 101
  • Karma: 2
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7.26
  • MySQL version: 5.5.30
  • PHP version: 5.3.17
Re: Prevent autofiling incoming email > activity from creating new users?
March 30, 2012, 01:31:11 pm
David -

Have you tried this yet?  I'm having the same problem and looking at the same hook but have not taken the leap into using hooks before.  It's one of my projects for the weekend.

I'll post if I get it to work.  I hope that you'll do the same (step-by-step on where to put the hook, for instance, would be an excellent addition for us newbies!).

I know that there's a good amount of documentation on how to use hooks, so I'm going to start there.

Good luck.
-tiffani

Tiffani Chin

  • I post occasionally
  • **
  • Posts: 101
  • Karma: 2
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7.26
  • MySQL version: 5.5.30
  • PHP version: 5.3.17
Re: Prevent autofiling incoming email > activity from creating new users?
March 30, 2012, 03:40:11 pm
OK, a little bit of progress here.  The hook on the page that Lobo referenced is, I think, more complicated than what we need for our purposes (David, not sure about you).  We basically don't want the system to continue to create new accounts for incoming emails that it does not recognize (we have a program with a set number of participants -- so any new emails are either a) spam (don't want accounts for them) or b) attached to users who are in the system but just using a new email.

That post states that civimail essentially has three actions:
- Create new individual (i.e. use the found contactID or create new contact if needed) EMAILPROCESSOR_CREATE_INDIVIDUAL
- Use the returned contactID(s) instead: EMAILPROCESSOR_OVERRIDE
- Ignore this email address: EMAILPROCESSOR_IGNORE

So, essentially, we want to kill the "EMAILPROCESSOR_CREATE_INDIVIDUAL" action and just have the mail processor process the mail for the people it can find and ignore the rest.

So, I think the hook that we want is something like:

Code: [Select]
    function civitest_civicrm_emailProcessorContact( $email, $contactID, &$result ) {
        require_once 'CRM/Utils/Mail/Incoming.php';

        $result = array( 'action'    => CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE );

        return;
    }

Have not had a chance to dig into hooks and see exactly where such a hook would go... but I wanted to through it out there and see if it looks totally wrong to people.

Thanks in advance for any help,
-tiffani

david.a.king

  • I’m new here
  • *
  • Posts: 25
  • Karma: 0
  • CiviCRM version: 3.4.5
  • CMS version: drupal 6.22
  • MySQL version: 5.2
  • PHP version: 5.3
Re: Prevent autofiling incoming email > activity from creating new users?
May 09, 2012, 05:27:01 pm
Hi Tiffani - i'm afraid i haven't looked further into this - i found it somewhat confusing as i'm sure you can sympathise - I don't suppose you found/tried a solution?
David

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • Prevent autofiling incoming email > activity from creating new users?

This forum was archived on 2017-11-26.