Answers.Body: <p>Resolved this by creating a new email template, it seems as if something in the template was causing the problem.</p>
  <p>No idea what, but this was the way we fixed the issue.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-13T07:19:12.933Z
Answers.LastActivityDate: 2020-08-13T07:19:12.933Z
Answers.UserDisplayName: Barijohn
Body: <p>I have a mailing group, which isn't a smart group, that always fails at 42%. I then add the successful ones to a group and resend the mailing and exclude that group. This then sends 32%. I repeat the above and the mailing is successful. This is the only mailing group on this site that is causing the problem and they send a lot of emails.</p>
  <p>I check the logs and get this error:</p>
  <pre><code>&quot;$Fatal Error Details = Array ( 
    [callback] =&gt; Array ( 
       [0] =&gt; CRM_Core_Error 
       [1] =&gt; exceptionHandler ) 
    [code] =&gt; -2 
    [message] =&gt; DB Error: syntax error 
    [mode] =&gt; 16 
    [debug_info] =&gt; SELECT a.id as `id`, a.name as `name` FROM civicrm_mailing a 
      WHERE (a.name LIKE &quot;%success%&quot;) 
      ORDER BY a.is_archived, a.scheduled_date DESC 
      LIMIT 11 
      OFFSET -10 
    [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-10' at line 6] 
    [type] =&gt; DB_Error 
    [user_info] =&gt; SELECT a.id as `id`, a.name as `name` 
      FROM civicrm_mailing a 
      WHERE (a.name LIKE &quot;%success%&quot;) 
      ORDER BY a.is_archived, a.scheduled_date DESC 
      LIMIT 11 
      OFFSET -10 
    [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-10' at line 6] 
    [to_string] =&gt; [db_error: message=&quot;DB Error: syntax error&quot; code=-2 mode=callback callback=CRM_Core_Error::exceptionHandler prefix=&quot;&quot; info=&quot;SELECT a.id as `id`, a.name as `name` FROM civicrm_mailing a WHERE (a.name LIKE &quot;%success%&quot;) ORDER BY a.is_archived, a.scheduled_date DESC LIMIT 11 OFFSET -10 [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-10' at line 6]&quot;] 
  )&quot;
  </code></pre>
  <p>I then get a lot of errors around blank email body so skipping emails.</p>
  <pre><code>CiviMail will not send an empty mail body, Skipping: 
  </code></pre>
  <p>I have created a new group, added people to it and retested it with the same results.</p>
  <p>Nothing obvious that I can see is causing the problem so I am at a loss to resolve it.</p>
  <p>Cheers
  Bari</p>
  <p>Backtrace:</p>
  <pre><code>  `$backTrace = 
    #0 /home/Site/public_html/sites/all/modules/civicrm/CRM/Core/Error.php(915): CRM_Core_Error::backtrace(&quot;backTrace&quot;, TRUE) 
    #1 /home/Site/public_html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(922): CRM_Core_Error::exceptionHandler(Object(DB_Error)) 
    #2 /home/Site/public_html/sites/all/modules/civicrm/packages/DB.php(998): PEAR_Error-&gt;__construct(&quot;DB Error: syntax error&quot;, -2, 16, (Array:2), &quot;SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...&quot;) 
    #3 /home/Site/public_html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error-&gt;__construct(-2, 16, (Array:2), &quot;SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...&quot;) 
    #4 /home/Site/public_html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR-&gt;_raiseError(Object(DB_mysqli), NULL, -2, 16, (Array:2), &quot;SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...&quot;, &quot;DB_Error&quot;, TRUE) 
    #5 /home/Site/public_html/sites/all/modules/civicrm/packages/DB/common.php(1925): PEAR-&gt;__call(&quot;raiseError&quot;, (Array:7)) 
    #6 /home/Site/public_html/sites/all/modules/civicrm/packages/DB/mysqli.php(935): DB_common-&gt;raiseError(-2, NULL, NULL, &quot;SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...&quot;, &quot;1064 ** You have an error in your SQL syntax; check the manual that correspon...&quot;) 
    #7 /home/Sitepublic_html/sites/all/modules/civicrm/packages/DB/mysqli.php(405): DB_mysqli-&gt;mysqliRaiseError() 
    #8 /home/Site/public_html/sites/all/modules/civicrm/packages/DB/common.php(1231): DB_mysqli-&gt;simpleQuery(&quot;SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...&quot;) 
    #9 /home/Site/public_html/sites/all/modules/civicrm/packages/DB/DataObject.php(2696): DB_common-&gt;query(&quot;SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...&quot;) 
    #10 /home/Site/public_html/sites/all/modules/civicrm/packages/DB/DataObject.php(1829): DB_DataObject-&gt;_query(&quot;SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...&quot;) 
    #11 /home/Site/public_html/sites/all/modules/civicrm/CRM/Core/DAO.php(421): DB_DataObject-&gt;query(&quot;SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...&quot;) 
    #12 /home/Site/public_html/sites/all/modules/civicrm/CRM/Core/DAO.php(1408): CRM_Core_DAO-&gt;query(&quot;SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...&quot;, TRUE) 
    #13 /home/Site/public_html/sites/all/modules/civicrm/Civi/API/SelectQuery.php(127): CRM_Core_DAO::executeQuery(&quot;SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...&quot;) 
    #14 /home/Site/public_html/sites/all/modules/civicrm/api/v3/utils.php(1260): Civi\API\SelectQuery-&gt;run() 
    #15 /home/Site/public_html/sites/all/modules/civicrm/api/v3/Mailing.php(238): _civicrm_api3_basic_get(&quot;CRM_Mailing_BAO_Mailing&quot;, (Array:8), TRUE, &quot;Mailing&quot;) 
    #16 /home/Site/public_html/sites/all/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_mailing_get((Array:8)) 
    #17 /home/Site/public_html/sites/all/modules/civicrm/Civi/API/Kernel.php(150): Civi\API\Provider\MagicFunctionProvider-&gt;invoke((Array:8)) 
    #18 /home/Site/public_html/sites/all/modules/civicrm/Civi/API/Kernel.php(81): Civi\API\Kernel-&gt;runRequest((Array:8)) 
    #19 /home/Site/public_html/sites/all/modules/civicrm/api/api.php(131): Civi\API\Kernel-&gt;runSafe(&quot;mailing&quot;, &quot;get&quot;, (Array:8)) 
    #20 /home/Site/public_html/sites/all/modules/civicrm/api/v3/Generic/Getlist.php(39): civicrm_api3(&quot;mailing&quot;, &quot;get&quot;, (Array:8)) 
    #21 /home/Site/public_html/sites/all/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(85): civicrm_api3_generic_getList((Array:8)) 
    #22 /home/Site/public_html/sites/all/modules/civicrm/Civi/API/Kernel.php(150): Civi\API\Provider\MagicFunctionProvider-&gt;invoke((Array:8)) 
    #23 /home/Site/public_html/sites/all/modules/civicrm/Civi/API/Kernel.php(81): Civi\API\Kernel-&gt;runRequest((Array:8)) 
    #24 /home/Site/public_html/sites/all/modules/civicrm/api/api.php(22): Civi\API\Kernel-&gt;runSafe(&quot;Mailing&quot;, &quot;getlist&quot;, (Array:6)) 
    #25 /home/Site/public_html/sites/all/modules/civicrm/CRM/Utils/REST.php(300): civicrm_api(&quot;Mailing&quot;, &quot;getlist&quot;, (Array:6)) 
    #26 /home/Site/public_html/sites/all/modules/civicrm/CRM/Utils/REST.php(550): CRM_Utils_REST::process((Array:3), (Array:6)) 
    #27 /home/Site/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(277): CRM_Utils_REST::ajax() 
    #28 /home/Site/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(68): CRM_Core_Invoke::runItem((Array:12)) 
    #29 /home/Site/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke((Array:3)) 
    #30 /home/Site/public_html/sites/all/modules/civicrm/drupal/civicrm.module(456): CRM_Core_Invoke::invoke((Array:3)) 
    #31 /home/Site/public_html/includes/menu.inc(527): civicrm_invoke(&quot;ajax&quot;, &quot;rest&quot;) 
    #32 /home/Site/public_html/index.php(21): menu_execute_active_handler() 
    #33 {main}&quot;`
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-11T08:12:54.173Z
Comments.Text: So it doesn't like "OFFSET -10".  Do the logs also show the backtrace of the code resulting in the error?
Comments.UserDisplayName: Aidan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-11T08:23:21.543Z
Comments.Text: Added backtrace, not very good formatting, I need to learn this!
Comments.UserDisplayName: Barijohn
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-11T16:24:33.503Z
Comments.Text: Just throw in some line breaks and spaces at the start of lines ::-)
Comments.UserDisplayName: Aidan
Tags: <civimail>
Title: Specific mailing always fails with 42% success rate
ThreadText: # Specific mailing always fails with 42% success rate
  
  (Asked by: username_0 on 2020-06-11)
  
  I have a mailing group, which isn't a smart group, that always fails at 42%. I then add the successful ones to a group and resend the mailing and exclude that group. This then sends 32%. I repeat the above and the mailing is successful. This is the only mailing group on this site that is causing the problem and they send a lot of emails.
  
  I check the logs and get this error:
  
  ```
  "$Fatal Error Details = Array ( 
    [callback] => Array ( 
       [0] => CRM_Core_Error 
       [1] => exceptionHandler ) 
    [code] => -2 
    [message] => DB Error: syntax error 
    [mode] => 16 
    [debug_info] => SELECT a.id as `id`, a.name as `name` FROM civicrm_mailing a 
      WHERE (a.name LIKE "%success%") 
      ORDER BY a.is_archived, a.scheduled_date DESC 
      LIMIT 11 
      OFFSET -10 
    [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-10' at line 6] 
    [type] => DB_Error 
    [user_info] => SELECT a.id as `id`, a.name as `name` 
      FROM civicrm_mailing a 
      WHERE (a.name LIKE "%success%") 
      ORDER BY a.is_archived, a.scheduled_date DESC 
      LIMIT 11 
      OFFSET -10 
    [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-10' at line 6] 
    [to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::exceptionHandler prefix="" info="SELECT a.id as `id`, a.name as `name` FROM civicrm_mailing a WHERE (a.name LIKE "%success%") ORDER BY a.is_archived, a.scheduled_date DESC LIMIT 11 OFFSET -10 [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-10' at line 6]"] 
  )"
  
  ```
  
  I then get a lot of errors around blank email body so skipping emails.
  
  ```
  CiviMail will not send an empty mail body, Skipping: 
  
  ```
  
  I have created a new group, added people to it and retested it with the same results.
  
  Nothing obvious that I can see is causing the problem so I am at a loss to resolve it.
  
  Cheers
  Bari
  
  Backtrace:
  
  ```
    `$backTrace = 
    #0 /home/Site/public_html/sites/all/modules/civicrm/CRM/Core/Error.php(915): CRM_Core_Error::backtrace("backTrace", TRUE) 
    #1 /home/Site/public_html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(922): CRM_Core_Error::exceptionHandler(Object(DB_Error)) 
    #2 /home/Site/public_html/sites/all/modules/civicrm/packages/DB.php(998): PEAR_Error->__construct("DB Error: syntax error", -2, 16, (Array:2), "SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...") 
    #3 /home/Site/public_html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error->__construct(-2, 16, (Array:2), "SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...") 
    #4 /home/Site/public_html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR->_raiseError(Object(DB_mysqli), NULL, -2, 16, (Array:2), "SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...", "DB_Error", TRUE) 
    #5 /home/Site/public_html/sites/all/modules/civicrm/packages/DB/common.php(1925): PEAR->__call("raiseError", (Array:7)) 
    #6 /home/Site/public_html/sites/all/modules/civicrm/packages/DB/mysqli.php(935): DB_common->raiseError(-2, NULL, NULL, "SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...", "1064 ** You have an error in your SQL syntax; check the manual that correspon...") 
    #7 /home/Sitepublic_html/sites/all/modules/civicrm/packages/DB/mysqli.php(405): DB_mysqli->mysqliRaiseError() 
    #8 /home/Site/public_html/sites/all/modules/civicrm/packages/DB/common.php(1231): DB_mysqli->simpleQuery("SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...") 
    #9 /home/Site/public_html/sites/all/modules/civicrm/packages/DB/DataObject.php(2696): DB_common->query("SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...") 
    #10 /home/Site/public_html/sites/all/modules/civicrm/packages/DB/DataObject.php(1829): DB_DataObject->_query("SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...") 
    #11 /home/Site/public_html/sites/all/modules/civicrm/CRM/Core/DAO.php(421): DB_DataObject->query("SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...") 
    #12 /home/Site/public_html/sites/all/modules/civicrm/CRM/Core/DAO.php(1408): CRM_Core_DAO->query("SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...", TRUE) 
    #13 /home/Site/public_html/sites/all/modules/civicrm/Civi/API/SelectQuery.php(127): CRM_Core_DAO::executeQuery("SELECT a.id as `id`, a.name as `name`\nFROM civicrm_mailing a\nWHERE (a.name ...") 
    #14 /home/Site/public_html/sites/all/modules/civicrm/api/v3/utils.php(1260): Civi\API\SelectQuery->run() 
    #15 /home/Site/public_html/sites/all/modules/civicrm/api/v3/Mailing.php(238): _civicrm_api3_basic_get("CRM_Mailing_BAO_Mailing", (Array:8), TRUE, "Mailing") 
    #16 /home/Site/public_html/sites/all/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_mailing_get((Array:8)) 
    #17 /home/Site/public_html/sites/all/modules/civicrm/Civi/API/Kernel.php(150): Civi\API\Provider\MagicFunctionProvider->invoke((Array:8)) 
    #18 /home/Site/public_html/sites/all/modules/civicrm/Civi/API/Kernel.php(81): Civi\API\Kernel->runRequest((Array:8)) 
    #19 /home/Site/public_html/sites/all/modules/civicrm/api/api.php(131): Civi\API\Kernel->runSafe("mailing", "get", (Array:8)) 
    #20 /home/Site/public_html/sites/all/modules/civicrm/api/v3/Generic/Getlist.php(39): civicrm_api3("mailing", "get", (Array:8)) 
    #21 /home/Site/public_html/sites/all/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(85): civicrm_api3_generic_getList((Array:8)) 
    #22 /home/Site/public_html/sites/all/modules/civicrm/Civi/API/Kernel.php(150): Civi\API\Provider\MagicFunctionProvider->invoke((Array:8)) 
    #23 /home/Site/public_html/sites/all/modules/civicrm/Civi/API/Kernel.php(81): Civi\API\Kernel->runRequest((Array:8)) 
    #24 /home/Site/public_html/sites/all/modules/civicrm/api/api.php(22): Civi\API\Kernel->runSafe("Mailing", "getlist", (Array:6)) 
    #25 /home/Site/public_html/sites/all/modules/civicrm/CRM/Utils/REST.php(300): civicrm_api("Mailing", "getlist", (Array:6)) 
    #26 /home/Site/public_html/sites/all/modules/civicrm/CRM/Utils/REST.php(550): CRM_Utils_REST::process((Array:3), (Array:6)) 
    #27 /home/Site/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(277): CRM_Utils_REST::ajax() 
    #28 /home/Site/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(68): CRM_Core_Invoke::runItem((Array:12)) 
    #29 /home/Site/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke((Array:3)) 
    #30 /home/Site/public_html/sites/all/modules/civicrm/drupal/civicrm.module(456): CRM_Core_Invoke::invoke((Array:3)) 
    #31 /home/Site/public_html/includes/menu.inc(527): civicrm_invoke("ajax", "rest") 
    #32 /home/Site/public_html/index.php(21): menu_execute_active_handler() 
    #33 {main}"`
  
  ```
  
  **Tags:** civimail
  
  > **Comments:**
  > **username_1**: So it doesn't like "OFFSET -10".  Do the logs also show the backtrace of the code resulting in the error?  
  > **username_0**: Added backtrace, not very good formatting, I need to learn this!  
  > **username_1**: Just throw in some line breaks and spaces at the start of lines ::-)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-08-13. Score: 3
  
  Resolved this by creating a new email template, it seems as if something in the template was causing the problem.
  
  No idea what, but this was the way we fixed the issue.
  
  
  ---
  
  