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 Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • 'Send email to contacts' broken if contact has multiple Primary emails
Pages: [1]

Author Topic: 'Send email to contacts' broken if contact has multiple Primary emails  (Read 943 times)

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
'Send email to contacts' broken if contact has multiple Primary emails
December 04, 2014, 04:36:41 pm
When sending emails to contacts I get unexpected "Email will NOT be sent to N contacts" messages, even though the contacts all have valid email addresses, are not deceased and are not on-hold.

While digging I found one of my contacts had TWO primary email addresses.

What happens is ...
  • CRM_Contact_Form_Task_EmailCommon::buildQuickForm() calls CRM_Utils_Token::getTokenDetails() with the list of contact Ids as returned in the search results
  • CRM_Utils_Token::getTokenDetails() calls CRM_Contact_BAO_Query::apiQuery() passing in the number of contacts as the $count
  • The query is run with a LIMIT modifier
  • But the query joins the contact to the primary email, so if a contact has more than one Primary email, the LIMIT stops another contact's row being returned.

As this is Core code I'm not sure how to fix it. Could someone comment?

I don't know why a contact would have more than one Primary email, but I do remember merging contact records for the example I have.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: 'Send email to contacts' broken if contact has multiple Primary emails
December 04, 2014, 05:09:51 pm
That would be bad news if merging creates multiple primary emails - can you test and confirm/deny?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: 'Send email to contacts' broken if contact has multiple Primary emails
December 04, 2014, 11:58:16 pm
What version are you on? I remember doing a merge of contacts in civi (4.5 version) and remember sending an e-mail to the wrong e-mail address. I thought I had done the merge wrong but it might be core code.... So I set the right e-mail address to primary by hand.
Developer at Edeveloper / CiviCoop

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: 'Send email to contacts' broken if contact has multiple Primary emails
December 07, 2014, 03:17:15 pm
I'm on 4.5.3. I've been unable to reproduce the problem (multiple primary emails) by merging contacts.

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: 'Send email to contacts' broken if contact has multiple Primary emails
December 08, 2014, 12:22:08 am
I tried to duplicate the issue on a civi 4.5.4 install and it looks everything works fine. I merged a contact and I got only one primary e-mail address
Developer at Edeveloper / CiviCoop

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: 'Send email to contacts' broken if contact has multiple Primary emails
December 08, 2014, 07:13:56 pm
On my production machine I merged 2 contact records and the resulting contact had 2 primary emails.

I just tried reproducing that on my test server and couldn't replicate it. This is weird.

prdsutte

  • I’m new here
  • *
  • Posts: 7
  • Karma: 0
  • CiviCRM version: 4.5
  • CMS version: Drupal
  • MySQL version: 5
  • PHP version: 5.5
Re: 'Send email to contacts' broken if contact has multiple Primary emails
April 17, 2015, 03:26:52 am
we had a similar problem with a client just now.
It's indeed an issue with primary emailadresses.
send email to contacts becomes broken.
version: 4.5.6

trying to replicate other cases where it happens.
we had a case recently where merging of adresses was a problem.
trying to collect more data where/when it happens.

« Last Edit: April 17, 2015, 04:47:47 am by prdsutte »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • 'Send email to contacts' broken if contact has multiple Primary emails

This forum was archived on 2017-11-26.