Answers.Body: <p>The only logical explanation to the above was that someone had overwritten Phone to Mobile and Mobile to Phone which was why you were seeing perverse results.</p>
  <p>Checking in log_civicrm_option_value table for option_group_id = 35 (which is phone type) and seeing if it has changed and if so when/who may confirm this</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-08T15:22:20.120Z
Answers.Text: accepted, thank you.
Answers.UserDisplayName: yurg
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-07T20:01:26.530Z
Answers.LastActivityDate: 2020-12-07T20:01:26.530Z
Answers.UserDisplayName: petednz - fuzion
Answers.Body: <p><strong>Kudos to Demerit and petednz-fuzion for helpful pointers, see below:</strong></p>
  <ul>
  <li>Demerit: Dummy SMS extension</li>
  <li>petednz-fuzion: check your log_civicrm_option_value table for option_group_id = 35 to see who changed it</li>
  </ul>
  <hr />
  <p>It is possible to find recipients of each mailing (even scheduled/not sent) via MySQL following these steps:</p>
  <ol>
  <li>Table <strong>log_civicrm_mailing</strong> gives us our Mass SMS id</li>
  <li>Table <strong>civicrm_mailing_recipients</strong> contains all recipients of all mailings (mass sms included) in the format:
  <em>mailing_id/contact_id/email_id/phone_id</em></li>
  <li>From here we can explore each <strong>&quot;phone_id&quot;</strong>  record in <strong>civicrm_phone</strong> table, where we can see <strong>&quot;phone_type_id&quot;</strong>.</li>
  </ol>
  <p>And this is a funny part: all my 5 recipients have phone_type_id=2 (&quot;Phone&quot;) while &quot;Mobile&quot; phone type has phone_type_id=1. So, it seems Mass SMS in my case checks if phone type is <strong>Phone</strong>, not <strong>Mobile</strong>.</p>
  <p>Advanced Search by &quot;Phone type=Phone&quot; returns only 3 numbers, but it seems to be another story. Perhaps, it worth checking what exactly happens on line 227 of \CRM\Mailing\BAO\Mailing.php in this regards:</p>
  <pre><code>'location_filter' =&gt; CRM_Utils_SQL_Select::fragment()-&gt;where(&quot;$entityTable.phone_type_id = &quot; . CRM_Core_PseudoConstant::getKey('CRM_Core_DAO_Phone', 'phone_type_id', 'Mobile')),
  </code></pre>
  <p><a href="https://i.sstatic.net/IQgoT.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/IQgoT.png" alt="Bingo!" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-06T18:06:25.477Z
Answers.Text: "funny part: all my 5 recipients have phone_type_id=2 ("Phone")" This doesn't seem correct and is core of your issue I think. Compare with https://dmaster.demo.civicrm.org/civicrm/admin/options?gid=35&reset=1 - where you will see Phone option is 1 and Mobile option is 2
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-06T18:08:03.113Z
Answers.Text: and check your log_civicrm_option_value table for option_group_id = 35 to see who changed it
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-06T18:09:01.933Z
Answers.Text: or is it a translation issue?
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-06T20:33:17.900Z
Answers.Text: @petednz-fuzion Wish I could add x100 votes for "log_civicrm_option_value table for option_group_id = 35" - this one is priceless. I've been asked to check this setup so have no clue who did what there.
Answers.UserDisplayName: yurg
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-07T00:10:42.647Z
Answers.Text: if you mean 'yes, that was the problem' should i add it as another answer - or do you want to add to yours.
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-07T11:48:44.567Z
Answers.Text: @petednz-fuzion The problem was essentially in renaming/reordering an order of options for phone field, but if we add this as the answer, it might be a little bit too short for those who'd like to debug, landing here for the same reason but with a different cause. Should you like to add your notes as another answer, I'll gladly accept it - for me personally, discovering "log_civicrm_option_value table"  and "option_group_id" is a huge piece of my learning curve.
Answers.UserDisplayName: yurg
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-06T17:39:56.690Z
Answers.LastActivityDate: 2020-12-07T11:55:31.783Z
Answers.LastEditDate: 2020-12-07T11:55:31.783Z
Answers.UserDisplayName: yurg
Body: <p><em>Wordpress 5.5.3, CiviCRM 5.31.0.</em>
  While testing Mass SMS with new Twilio account we've discovered it does not quite work. Searching for a solution here and across lab.civicrm.org haven't helped much. Logs are empty so it is not an error or is not considered as an error by CiviCRM. The most popular related solution ( replace &quot;is_deceased&quot; from NULl to 0 in the database ) hasn't helped. Mass mailing works fine and the number of recipiens counted is correct. Individual SMS sending works also. The only clues we have are:</p>
  <ul>
  <li>&quot;Send SMS&quot; action is not visible for individual contacts.</li>
  <li>Attempt to create Mass SMS for all contacts in the database ( around 10 000 ) displays only <strong>5</strong>  contacts on &quot;Total Recipients: 5&quot; counter.
  Probably it is something with data in the database. We were having big updates for both wordpress and civi past weeks on a decent hosting so things might have been a little messy. The question is, where to start with debugging. Perhaps, if we saw which exactly contacts were counted, we would be able to find what all these 5 have in common and figure out the next steps. Any clue will be helpful.</li>
  </ul>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-05T00:05:16.263Z
Comments.Text: Quick question: do all the recipients have the phone type set to Mobile?
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-05T01:26:38.860Z
Comments.Text: are all the phones set up as Mobile? Do they all have a verifiable mobile number? Can you send individual SMS to any of the numbers that are not included in the 5 that show?
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-06T15:00:07.177Z
Comments.Text: @Demerit thank you for your note: unfortunately, the most of them have. I've even tried to change phone type from Home -Mobile to Main - Mobile hoping it will make any difference - no dice.
Comments.UserDisplayName: yurg
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-06T15:13:27.600Z
Comments.Text: Ok another thing to check is if the contacts have "Do not SMS" checked under the communication prefs accordion on their contact record.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-06T15:22:03.327Z
Comments.Text: @petednz-fuzion thank you for your notes. Yes, most of the phones are mobile (around 5k out of 10). Funny coincidence though, a number of contacts found via "Advanced search > Do not SMS" was also 5 so first I thought there is the wrong condition set somewhere in the code, but even after I've added "No SMS" to some more contacts, the total number of counted mass sms contact was not changed. Yes, I can send individual SMS but not from a contact page Actions - there is no "Send SMS" action visible. Wish I knew how to find out who are these 5 lucky numbered contacts .
Comments.UserDisplayName: yurg
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-06T15:25:21.203Z
Comments.Text: @Demerit "Advanced search > Include by Privacy options > Do not SMS" gives 108 - was 5 first time I checked but after I added some more, the total number of mass sms recipient did not change, still 5.
Comments.UserDisplayName: yurg
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-06T15:44:09.947Z
Comments.Text: If you go to search -> find activities and search for type = outbound sms, that should tell you who.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-06T16:55:19.507Z
Comments.Text: @Demerit Perhaps it should if SMS  has been sent already which was not yet happened - I'd like to find out to whom it goes first. Good point btw. - some temporary table should be created to store data before sending.
Comments.UserDisplayName: yurg
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-06T17:16:35.207Z
Comments.Text: Use the Dummy SMS extension to send. Then you can see without actually sending.
Comments.UserDisplayName: Demerit
Tags: <wordpress><mailing><sms><twilio>
Title: Mass SMS recipients count
ThreadText: # Mass SMS recipients count
  
  (Asked by: username_0 on 2020-12-04)
  
  *Wordpress 5.5.3, CiviCRM 5.31.0.*
  While testing Mass SMS with new Twilio account we've discovered it does not quite work. Searching for a solution here and across lab.civicrm.org haven't helped much. Logs are empty so it is not an error or is not considered as an error by CiviCRM. The most popular related solution ( replace "is\_deceased" from NULl to 0 in the database ) hasn't helped. Mass mailing works fine and the number of recipiens counted is correct. Individual SMS sending works also. The only clues we have are:
  
  * "Send SMS" action is not visible for individual contacts.
  * Attempt to create Mass SMS for all contacts in the database ( around 10 000 ) displays only **5** contacts on "Total Recipients: 5" counter.
    Probably it is something with data in the database. We were having big updates for both wordpress and civi past weeks on a decent hosting so things might have been a little messy. The question is, where to start with debugging. Perhaps, if we saw which exactly contacts were counted, we would be able to find what all these 5 have in common and figure out the next steps. Any clue will be helpful.
  
  **Tags:** wordpress, mailing, sms, twilio
  
  > **Comments:**
  > **username_1**: Quick question: do all the recipients have the phone type set to Mobile?  
  > **username_2**: are all the phones set up as Mobile? Do they all have a verifiable mobile number? Can you send individual SMS to any of the numbers that are not included in the 5 that show?  
  > **username_0**: @username_1 thank you for your note: unfortunately, the most of them have. I've even tried to change phone type from Home -Mobile to Main - Mobile hoping it will make any difference - no dice.  
  > **username_1**: Ok another thing to check is if the contacts have "Do not SMS" checked under the communication prefs accordion on their contact record.  
  > **username_0**: @petednz-fuzion thank you for your notes. Yes, most of the phones are mobile (around 5k out of 10). Funny coincidence though, a number of contacts found via "Advanced search > Do not SMS" was also 5 so first I thought there is the wrong condition set somewhere in the code, but even after I've added "No SMS" to some more contacts, the total number of counted mass sms contact was not changed. Yes, I can send individual SMS but not from a contact page Actions - there is no "Send SMS" action visible. Wish I knew how to find out who are these 5 lucky numbered contacts .  
  > **username_0**: @username_1 "Advanced search > Include by Privacy options > Do not SMS" gives 108 - was 5 first time I checked but after I added some more, the total number of mass sms recipient did not change, still 5.  
  > **username_1**: If you go to search -> find activities and search for type = outbound sms, that should tell you who.  
  > **username_0**: @username_1 Perhaps it should if SMS  has been sent already which was not yet happened - I'd like to find out to whom it goes first. Good point btw. - some temporary table should be created to store data before sending.  
  > **username_1**: Use the Dummy SMS extension to send. Then you can see without actually sending.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2020-12-07. Score: 2 | Accepted answer
  
  The only logical explanation to the above was that someone had overwritten Phone to Mobile and Mobile to Phone which was why you were seeing perverse results.
  
  Checking in log\_civicrm\_option\_value table for option\_group\_id = 35 (which is phone type) and seeing if it has changed and if so when/who may confirm this
  
  > **Comments:**
  > **username_0**: accepted, thank you.  
  
  ---
  
  ### Answer by username_0 on 2020-12-06. Score: 2
  
  Kudos to username_1 and petednz-fuzion for helpful pointers, see below:
  
  username_1: Dummy SMS extension
  petednz-fuzion: check your log_civicrm_option_value table for option_group_id = 35 to see who changed it
  
  
  It is possible to find recipients of each mailing (even scheduled/not sent) via MySQL following these steps:
  
  Table log_civicrm_mailing gives us our Mass SMS id
  Table civicrm_mailing_recipients contains all recipients of all mailings (mass sms included) in the format:
  mailing_id/contact_id/email_id/phone_id
  From here we can explore each "phone_id"  record in civicrm_phone table, where we can see "phone_type_id".
  
  And this is a funny part: all my 5 recipients have phone_type_id=2 ("Phone") while "Mobile" phone type has phone_type_id=1. So, it seems Mass SMS in my case checks if phone type is Phone, not Mobile.
  Advanced Search by "Phone type=Phone" returns only 3 numbers, but it seems to be another story. Perhaps, it worth checking what exactly happens on line 227 of \CRM\Mailing\BAO\Mailing.php in this regards:
  'location_filter' => CRM_Utils_SQL_Select::fragment()->where("$entityTable.phone_type_id = " . CRM_Core_PseudoConstant::getKey('CRM_Core_DAO_Phone', 'phone_type_id', 'Mobile')),
  
  > **Comments:**
  > **username_2**: "funny part: all my 5 recipients have phone_type_id=2 ("Phone")" This doesn't seem correct and is core of your issue I think. Compare with https://dmaster.demo.civicrm.org/civicrm/admin/options?gid=35&reset=1 - where you will see Phone option is 1 and Mobile option is 2  
  > **username_2**: and check your log_civicrm_option_value table for option_group_id = 35 to see who changed it  
  > **username_2**: or is it a translation issue?  
  > **username_0**: @petednz-fuzion Wish I could add x100 votes for "log_civicrm_option_value table for option_group_id = 35" - this one is priceless. I've been asked to check this setup so have no clue who did what there.  
  > **username_2**: if you mean 'yes, that was the problem' should i add it as another answer - or do you want to add to yours.  
  > **username_0**: @petednz-fuzion The problem was essentially in renaming/reordering an order of options for phone field, but if we add this as the answer, it might be a little bit too short for those who'd like to debug, landing here for the same reason but with a different cause. Should you like to add your notes as another answer, I'll gladly accept it - for me personally, discovering "log_civicrm_option_value table"  and "option_group_id" is a huge piece of my learning curve.  
  
  ---
  
  