Answers.Body: <p>Well I think the dirty work is done here in a sql statement using a group by clause. I don't know the code base at all however. I am on win7 and use the grepWin program.</p>
  
  <p>..\civicrm\civicrm\CRM\Mailing\BAO\Mailing.php</p>
  
  <p>Line 558</p>
  
  <pre><code>  // CRM-3975
    $groupBy = $groupJoin = '';
    if ($dedupeEmail) {
      $groupJoin = " INNER JOIN civicrm_email e ON e.id = i.email_id";
      $groupBy = " GROUP BY e.email ";
    }
  </code></pre>
  
  <p>CiviMail should have the option of not sending duplicate emails
  <a href="https://issues.civicrm.org/jira/browse/CRM-3975" rel="nofollow">https://issues.civicrm.org/jira/browse/CRM-3975</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-06T05:07:25.697Z
Answers.LastActivityDate: 2016-01-06T05:07:25.697Z
Answers.UserDisplayName: P a u l
Body: <p>CiviMail has a great feature that finds intended recipients with the same email address prior to a mailing and prevents multiple emails getting sent to the same address.  It seems similar to the Merge Address or Merge Household features in the Export action. <strong>Where in the code base is the CiviMail merge functionality located?</strong></p>
  
  <p>I'd like to create a similar function for CiviSMS and am looking for a starting point.</p>
  
  <p>Based on the merge functions I've found in Export (<a href="https://github.com/civicrm/civicrm-core/blob/master/CRM/Export/BAO/Export.php" rel="nofollow">https://github.com/civicrm/civicrm-core/blob/master/CRM/Export/BAO/Export.php</a>), I've tried a few different searches on GitHub for the CiviMail merge function like "mergeemail" or "merge_email" but can't find anything yet.</p>
  
Tags: <civimail><civisms>
Title: Where is the merge function for CiviMail located in code?
ThreadText: # Where is the merge function for CiviMail located in code?
  
  (Asked by: username_0 on 2016-01-06)
  
  CiviMail has a great feature that finds intended recipients with the same email address prior to a mailing and prevents multiple emails getting sent to the same address. It seems similar to the Merge Address or Merge Household features in the Export action. **Where in the code base is the CiviMail merge functionality located?**
  
  I'd like to create a similar function for CiviSMS and am looking for a starting point.
  
  Based on the merge functions I've found in Export (<https://github.com/civicrm/civicrm-core/blob/master/CRM/Export/BAO/Export.php>), I've tried a few different searches on GitHub for the CiviMail merge function like "mergeemail" or "merge\_email" but can't find anything yet.
  
  **Tags:** civimail, civisms
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-01-06. Score: 1
  
  Well I think the dirty work is done here in a sql statement using a group by clause. I don't know the code base at all however. I am on win7 and use the grepWin program.
  ..\civicrm\civicrm\CRM\Mailing\BAO\Mailing.php
  Line 558
    // CRM-3975
    $groupBy = $groupJoin = '';
    if ($dedupeEmail) {
      $groupJoin = " INNER JOIN civicrm_email e ON e.id = i.email_id";
      $groupBy = " GROUP BY e.email ";
    }
  
  CiviMail should have the option of not sending duplicate emails
  https://issues.civicrm.org/jira/browse/CRM-3975
  
  
  ---
  
  