Answers.Body: <p>See issue <a href="https://issues.civicrm.org/jira/browse/CRM-18543" rel="nofollow">CRM-18543</a> and PR <a href="https://github.com/civicrm/civicrm-core/pull/8355" rel="nofollow">8355</a>.</p>
  
  <p>CRM-18345 changed the behaviour of the foreign keys on civicrm_mailing_recipient when deleting civicrm_email or civicrm_phone. The email_id and phone_id columns are made NULL rather than the row being cascade deleted.</p>
  
  <p>This means there can exist rows in civicrm_mailing_recipient where both these fields are NULL.</p>
  
  <p>So the Mailing Job software needs to handle rows where BOTH email_id and phone_id are NULL.</p>
  
  <p>I've supplied a patch that handles this case by ignoring such rows.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-12T02:06:37.973Z
Answers.LastActivityDate: 2016-05-12T02:06:37.973Z
Answers.UserDisplayName: Ken West
Body: <p>To reproduce ...</p>
  
  <ol>
  <li>Create a mailing that includes contact X as a recipient</li>
  <li>Delete the email address of X</li>
  <li>Send mailing</li>
  </ol>
  
  <p>The job fails trying to send an email to X. Each time the job runs it queues emails to send to the same set of contacts (those 'before' X). Job never completes.</p>
  
  <p>I suspect it's a side-effect of <a href="https://issues.civicrm.org/jira/browse/CRM-18345" rel="nofollow">https://issues.civicrm.org/jira/browse/CRM-18345</a></p>
  
Tags: <civimail>
Title: Why is 4.7.7 CiviMail failing trying to insert a row into civicrm_mailing_recipient?
ThreadText: # Why is 4.7.7 CiviMail failing trying to insert a row into civicrm_mailing_recipient?
  
  (Asked by: username_0 on 2016-05-11)
  
  To reproduce ...
  
  1. Create a mailing that includes contact X as a recipient
  2. Delete the email address of X
  3. Send mailing
  
  The job fails trying to send an email to X. Each time the job runs it queues emails to send to the same set of contacts (those 'before' X). Job never completes.
  
  I suspect it's a side-effect of <https://issues.civicrm.org/jira/browse/CRM-18345>
  
  **Tags:** civimail
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-05-12. Score: 1
  
  See issue [CRM-18543](https://issues.civicrm.org/jira/browse/CRM-18543) and PR [8355](https://github.com/civicrm/civicrm-core/pull/8355).
  
  CRM-18345 changed the behaviour of the foreign keys on civicrm\_mailing\_recipient when deleting civicrm\_email or civicrm\_phone. The email\_id and phone\_id columns are made NULL rather than the row being cascade deleted.
  
  This means there can exist rows in civicrm\_mailing\_recipient where both these fields are NULL.
  
  So the Mailing Job software needs to handle rows where BOTH email\_id and phone\_id are NULL.
  
  I've supplied a patch that handles this case by ignoring such rows.
  
  
  ---
  
  