Answers.Body: <p>Thanks to <a href="https://civicrm.stackexchange.com/questions/16613/civi-does-not-email-to-some-contacts-not-civimail-just-mail/16664#comment18521_16613" title="foo">michaelmcandrew's comment</a> I investigated deeper and found the reason being a bug. Created issue <a href="https://issues.civicrm.org/jira/browse/CRM-19876" rel="nofollow noreferrer">https://issues.civicrm.org/jira/browse/CRM-19876</a> which is really weird but contains a somehow simple patch (<a href="https://github.com/civicrm/civicrm-core/pull/9676" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/pull/9676</a>).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-13T16:51:34.150Z
Answers.Text: glad this worked for you. thanks for submitting the patch :)
Answers.UserDisplayName: michaelmcandrew
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-13T09:40:35.683Z
Answers.LastActivityDate: 2017-01-16T08:58:10.260Z
Answers.LastEditDate: 2017-04-13T12:53:13.167Z
Answers.UserDisplayName: nielo
Body: <p>We've got some contacts in a search result. Selecting all or checking "All x contacts" and choosing "Email - send now (to 50 or less)" leads to the email screen stating that three of the contacts won't receive the mail. But all of the possible reasons (is_deceased, do_not_email, ...) aren't true. The db says:</p>
  
  <pre><code>select do_not_email, is_deceased, is_opt_out from civicrm_contact where id = x;
  +--------------+-------------+------------+
  | do_not_email | is_deceased | is_opt_out |
  +--------------+-------------+------------+
  |            0 |           0 |          0 |
  +--------------+-------------+------------+
  
  select email, is_primary, on_hold from civicrm_email where contact_id = x;
  +--------------------------------+------------+---------+
  | email                          | is_primary | on_hold |
  +--------------------------------+------------+---------+
  | m.muster@domain.tld            |          1 |       0 |
  +--------------------------------+------------+---------+
  </code></pre>
  
  <p>The contacts in question are able to receive emails if triggered by »send email«-action in contact's summary and even when selected in the result's list. The problem occurs only when sending to bunch of contacts.</p>
  
  <p>Their email addresses seem valid and do not contain crazy chars.</p>
  
  <p>I just can't find any reason why civi sorts such contacts out. I've read </p>
  
  <ul>
  <li><a href="https://civicrm.stackexchange.com/questions/7377/why-are-contacts-not-receiving-emails-when-do-not-email-not-checked">Why are contacts not receiving emails when do not email not checked?</a> and</li>
  <li><a href="https://civicrm.stackexchange.com/questions/3835/which-contacts-in-a-mailing-group-are-not-recipients-of-a-mass-mailing/3858#3858">Which contacts in a mailing group are NOT recipients of a mass mailing?</a></li>
  </ul>
  
  <p>But nothing helped. Any ideas?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-11T10:50:27.323Z
Comments.Text: Could there be illegal characters in the email address such as a space at the end (happens sometime during import)? I guess you made sure contacts are not in trash as well...
Comments.UserDisplayName: Fabian
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-11T19:57:37.787Z
Comments.Text: Just to create a test case. Is the action "Send an email" available from the actions menu when the contact with the email "m.muster@domain.tld" is selected?
Comments.UserDisplayName: Kainuk - CiviCooP
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-11T20:36:08.063Z
Comments.Text: No illegal characters, Send email is possible.
Comments.UserDisplayName: nielo
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-12T20:06:57.963Z
Comments.Text: is it definitley something to do with these contacts? If you created a group with all three of them in, searched for members of the group and then chose Email Send Now to 50 or less, does it not send to them?
Comments.UserDisplayName: michaelmcandrew
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-12T20:27:27.247Z
Comments.Text: Since you have used some SQL in your question I am going to make the assumption that you might be OK with PHP as well.
  
  If you have a look at https://github.com/civicrm/civicrm-core/blob/master/CRM/Contact/Form/Task/EmailCommon.php#L242, you'll see the reasons that a contact can be excluded from the email (broadly as you have mentioned them). It's probably worth investigating what is happening in that function if you can.
Comments.UserDisplayName: michaelmcandrew
Tags: <email>
Title: Civi does not email to some contacts (Not CiviMail, just mail)
ThreadText: # Civi does not email to some contacts (Not CiviMail, just mail)
  
  (Asked by: username_0 on 2017-01-11)
  
  We've got some contacts in a search result. Selecting all or checking "All x contacts" and choosing "Email - send now (to 50 or less)" leads to the email screen stating that three of the contacts won't receive the mail. But all of the possible reasons (is\_deceased, do\_not\_email, ...) aren't true. The db says:
  
  ```
  select do_not_email, is_deceased, is_opt_out from civicrm_contact where id = x;
  +--------------+-------------+------------+
  | do_not_email | is_deceased | is_opt_out |
  +--------------+-------------+------------+
  |            0 |           0 |          0 |
  +--------------+-------------+------------+
  
  select email, is_primary, on_hold from civicrm_email where contact_id = x;
  +--------------------------------+------------+---------+
  | email                          | is_primary | on_hold |
  +--------------------------------+------------+---------+
  | m.muster@domain.tld            |          1 |       0 |
  +--------------------------------+------------+---------+
  
  ```
  
  The contacts in question are able to receive emails if triggered by »send email«-action in contact's summary and even when selected in the result's list. The problem occurs only when sending to bunch of contacts.
  
  Their email addresses seem valid and do not contain crazy chars.
  
  I just can't find any reason why civi sorts such contacts out. I've read
  
  * [Why are contacts not receiving emails when do not email not checked?](https://civicrm.stackexchange.com/questions/7377/why-are-contacts-not-receiving-emails-when-do-not-email-not-checked) and
  * [Which contacts in a mailing group are NOT recipients of a mass mailing?](https://civicrm.stackexchange.com/questions/3835/which-contacts-in-a-mailing-group-are-not-recipients-of-a-mass-mailing/3858#3858)
  
  But nothing helped. Any ideas?
  
  **Tags:** email
  
  > **Comments:**
  > **username_1**: Could there be illegal characters in the email address such as a space at the end (happens sometime during import)? I guess you made sure contacts are not in trash as well...  
  > **username_2**: Just to create a test case. Is the action "Send an email" available from the actions menu when the contact with the email "m.muster@domain.tld" is selected?  
  > **username_0**: No illegal characters, Send email is possible.  
  > **username_3**: is it definitley something to do with these contacts? If you created a group with all three of them in, searched for members of the group and then chose Email Send Now to 50 or less, does it not send to them?  
  > **username_3**: Since you have used some SQL in your question I am going to make the assumption that you might be OK with PHP as well.  If you have a look at https://github.com/civicrm/civicrm-core/blob/master/CRM/Contact/Form/Task/EmailCommon.php#L242, you'll see the reasons that a contact can be excluded from the email (broadly as you have mentioned them). It's probably worth investigating what is happening in that function if you can.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-01-13. Score: 5 | Accepted answer
  
  Thanks to [username_3's comment](https://civicrm.stackexchange.com/questions/16613/civi-does-not-email-to-some-contacts-not-civimail-just-mail/16664#comment18521_16613 "foo") I investigated deeper and found the reason being a bug. Created issue <https://issues.civicrm.org/jira/browse/CRM-19876> which is really weird but contains a somehow simple patch (<https://github.com/civicrm/civicrm-core/pull/9676>).
  
  > **Comments:**
  > **username_3**: glad this worked for you. thanks for submitting the patch :)  
  
  ---
  
  