Body: <p>I'm at a similar situation as in <a href="https://civicrm.stackexchange.com/questions/9457/mailings-are-started-but-not-sent-what-is-the-difference-between-a-scheduled-j?s=23|0.4802">this question</a>, which was a <a href="https://issues.civicrm.org/jira/browse/CRM-17968" rel="nofollow noreferrer">bug</a> that supposedly got fixed.</p>
  
  <p>Scheduled mailings get started by the cron job, but no mailings are sent and the job never finish.</p>
  
  <p>We had this at 4.7.17 and have just upgraded to 4.7.20 where it also exists.</p>
  
  <p>The job log indicate no error, there is nothing in the logs. BUT SEE UPDATE!</p>
  
  <p>Also running the job with "Run now" as the same user as the cron job sends and finishes the job. Running the same command as the cronjob (<code>php bin/cli.php -j &lt;site&gt; -u &lt;user&gt; -p &lt;passw&gt; -e Job -a execute</code>) from the servers command line does not send the mailings but the run is registered by the "Scheduled jobs" log.</p>
  
  <p>The <code>wget</code>method does not seem to work either, which indicates that it is not the same as <a href="https://civicrm.stackexchange.com/questions/9570/mailings-scheduler-fails-after-upgrade-to-4-7-1">the other issue</a>.</p>
  
  <p>UPDATE: There seems to be something related in the logs. It happens on the scheduling, so the timing is unrelated to the cronjobs, that's why I missed it.</p>
  
  <p>It's a missing field error (which might be <a href="https://civicrm.stackexchange.com/questions/18951/no-such-field-card-type-but-exists">triggers or something else...</a>). I've pasted the complete log at the end of the question. The relevant part is probably this:</p>
  
  <pre><code>[debug_info] =&gt;
  INSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )
  SELECT ANY_VALUE(265), ANY_VALUE(i.contact_id), ANY_VALUE(i.phone_id)
  FROM       civicrm_contact contact_a
  INNER JOIN I_1253 i ON contact_a.id = i.contact_id
              INNER JOIN civicrm_email e ON e.id = i.email_id
             WHERE contact_a.is_deleted = 0
              GROUP BY e.email
  ORDER BY   MIN(i.contact_id), MIN(i.phone_id)
   [nativecode=1054 ** Unknown column 'i.email_id' in 'on clause']
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>#9 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/mysqli.php(933): DB_common-&gt;raiseError(-19, NULL, NULL, NULL, "1054 ** Unknown column 'i.email_id' in 'on clause'")
  #10 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/mysqli.php(403): DB_mysqli-&gt;mysqliRaiseError()
  #11 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/common.php(1216): DB_mysqli-&gt;simpleQuery("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #12 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php(2446): DB_common-&gt;query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #13 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php(1635): DB_DataObject-&gt;_query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #14 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php(362): DB_DataObject-&gt;query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #15 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php(1315): CRM_Core_DAO-&gt;query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...", TRUE)
  #16 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Mailing/BAO/Mailing.php(565): CRM_Core_DAO::executeQuery("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...", (Array:1))
  #17 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Mailing/BAO/Mailing.php(1791): CRM_Mailing_BAO_Mailing::getRecipients("1253", "265", TRUE, "1", "sms")
  #18 [internal function](): CRM_Mailing_BAO_Mailing::create((Array:54))
  #19 /var/www/events/administrator/components/com_civicrm/civicrm/api/v3/utils.php(1284): call_user_func_array((Array:2), (Array:1))
  #20 /var/www/events/administrator/components/com_civicrm/civicrm/api/v3/Mailing.php(70): _civicrm_api3_basic_create("CRM_Mailing_BAO_Mailing", (Array:54))
  #21 /var/www/events/administrator/components/com_civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_mailing_create((Array:53))
  #22 /var/www/events/administrator/components/com_civicrm/civicrm/Civi/API/Kernel.php(169): Civi\API\Provider\MagicFunctionProvider-&gt;invoke((Array:9))
  #23 /var/www/events/administrator/components/com_civicrm/civicrm/Civi/API/Kernel.php(100): Civi\API\Kernel-&gt;runRequest((Array:7))
  #24 /var/www/events/administrator/components/com_civicrm/civicrm/api/api.php(23): Civi\API\Kernel-&gt;runSafe("Mailing", "create", (Array:53), NULL)
  #25 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Utils/REST.php(404): civicrm_api("Mailing", "create", (Array:53))
  </code></pre>
  
  <p>But if this happens so that the cronjob can't find the mailing, how can "Run now" do that?</p>
  
  <p>And what field in which table is it that's missing? My SQL is a bit rusty...</p>
  
  <p>How can I repair it?</p>
  
  <p>Here's the complete log:</p>
  
  <pre><code>Jun 15 10:43:40  [info] $Fatal Error Details = Array
  (
      [callback] =&gt; Array
          (
              [0] =&gt; CRM_Core_Error
              [1] =&gt; exceptionHandler
          )
      [code] =&gt; -19
      [message] =&gt; DB Error: no such field
      [mode] =&gt; 16
      [debug_info] =&gt;
  INSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )
  SELECT ANY_VALUE(265), ANY_VALUE(i.contact_id), ANY_VALUE(i.phone_id)
  FROM       civicrm_contact contact_a
  INNER JOIN I_1253 i ON contact_a.id = i.contact_id
              INNER JOIN civicrm_email e ON e.id = i.email_id
             WHERE contact_a.is_deleted = 0
              GROUP BY e.email
  ORDER BY   MIN(i.contact_id), MIN(i.phone_id)
   [nativecode=1054 ** Unknown column 'i.email_id' in 'on clause']
      [type] =&gt; DB_Error
      [user_info] =&gt;
  INSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )
  SELECT ANY_VALUE(265), ANY_VALUE(i.contact_id), ANY_VALUE(i.phone_id)
  FROM       civicrm_contact contact_a
  INNER JOIN I_1253 i ON contact_a.id = i.contact_id
              INNER JOIN civicrm_email e ON e.id = i.email_id
             WHERE contact_a.is_deleted = 0
              GROUP BY e.email
  ORDER BY   MIN(i.contact_id), MIN(i.phone_id)
   [nativecode=1054 ** Unknown column 'i.email_id' in 'on clause']
      [to_string] =&gt; [db_error: message="DB Error: no such field" code=-19 mode=callback callback=CRM_Core_Error::exceptionHandler prefix="" info="
  INSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )
  SELECT ANY_VALUE(265), ANY_VALUE(i.contact_id), ANY_VALUE(i.phone_id)
  FROM       civicrm_contact contact_a
  INNER JOIN I_1253 i ON contact_a.id = i.contact_id
              INNER JOIN civicrm_email e ON e.id = i.email_id
             WHERE contact_a.is_deleted = 0
              GROUP BY e.email
  ORDER BY   MIN(i.contact_id), MIN(i.phone_id)
   [nativecode=1054 ** Unknown column 'i.email_id' in 'on clause']"]
  )
  
  Jun 15 10:43:40  [info] $backTrace = #0 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/Error.php(944): CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 [internal function](): CRM_Core_Error::exceptionHandler(Object(DB_Error))
  #2 /var/www/events/administrator/components/com_civicrm/civicrm/packages/PEAR.php(921): call_user_func((Array:2), Object(DB_Error))
  #3 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB.php(985): PEAR_Error-&gt;__construct("DB Error: no such field", -19, 16, (Array:2), "\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #4 /var/www/events/administrator/components/com_civicrm/civicrm/packages/PEAR.php(575): DB_Error-&gt;__construct(-19, 16, (Array:2), "\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #5 [internal function](): PEAR-&gt;_raiseError(Object(DB_mysqli), NULL, -19, NULL, NULL, "\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...", "DB_Error", TRUE)
  #6 /var/www/events/administrator/components/com_civicrm/civicrm/packages/PEAR.php(224): call_user_func_array((Array:2), (Array:8))
  #7 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/common.php(1905): PEAR-&gt;__call("raiseError", (Array:7))
  #8 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/common.php(1905): PEAR-&gt;raiseError(NULL, -19, NULL, NULL, "\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...", "DB_Error", TRUE)
  #9 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/mysqli.php(933): DB_common-&gt;raiseError(-19, NULL, NULL, NULL, "1054 ** Unknown column 'i.email_id' in 'on clause'")
  #10 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/mysqli.php(403): DB_mysqli-&gt;mysqliRaiseError()
  #11 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/common.php(1216): DB_mysqli-&gt;simpleQuery("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #12 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php(2446): DB_common-&gt;query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #13 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php(1635): DB_DataObject-&gt;_query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #14 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php(362): DB_DataObject-&gt;query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #15 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php(1315): CRM_Core_DAO-&gt;query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...", TRUE)
  #16 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Mailing/BAO/Mailing.php(565): CRM_Core_DAO::executeQuery("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...", (Array:1))
  #17 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Mailing/BAO/Mailing.php(1791): CRM_Mailing_BAO_Mailing::getRecipients("1253", "265", TRUE, "1", "sms")
  #18 [internal function](): CRM_Mailing_BAO_Mailing::create((Array:54))
  #19 /var/www/events/administrator/components/com_civicrm/civicrm/api/v3/utils.php(1284): call_user_func_array((Array:2), (Array:1))
  #20 /var/www/events/administrator/components/com_civicrm/civicrm/api/v3/Mailing.php(70): _civicrm_api3_basic_create("CRM_Mailing_BAO_Mailing", (Array:54))
  #21 /var/www/events/administrator/components/com_civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_mailing_create((Array:53))
  #22 /var/www/events/administrator/components/com_civicrm/civicrm/Civi/API/Kernel.php(169): Civi\API\Provider\MagicFunctionProvider-&gt;invoke((Array:9))
  #23 /var/www/events/administrator/components/com_civicrm/civicrm/Civi/API/Kernel.php(100): Civi\API\Kernel-&gt;runRequest((Array:7))
  #24 /var/www/events/administrator/components/com_civicrm/civicrm/api/api.php(23): Civi\API\Kernel-&gt;runSafe("Mailing", "create", (Array:53), NULL)
  #25 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Utils/REST.php(404): civicrm_api("Mailing", "create", (Array:53))
  #26 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Utils/REST.php(641): CRM_Utils_REST::process((Array:3), (Array:51))
  #27 [internal function](): CRM_Utils_REST::ajax()
  #28 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(276): call_user_func((Array:2))
  #29 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:12))
  #30 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3))
  #31 /var/www/events/administrator/components/com_civicrm/civicrm.php(121): CRM_Core_Invoke::invoke((Array:3))
  #32 /var/www/events/administrator/components/com_civicrm/civicrm.php(40): civicrm_invoke()
  #33 /var/www/events/libraries/cms/component/helper.php(394): require_once("/var/www/events/administrator/components/com_civicrm/civicrm.php")
  #34 /var/www/events/libraries/cms/component/helper.php(369): JComponentHelper::executeComponent("/var/www/events/administrator/components/com_civicrm/civicrm.php")
  #35 /var/www/events/libraries/cms/application/administrator.php(98): JComponentHelper::renderComponent("com_civicrm")
  #36 /var/www/events/libraries/cms/application/administrator.php(156): JApplicationAdministrator-&gt;dispatch()
  #37 /var/www/events/libraries/cms/application/cms.php(265): JApplicationAdministrator-&gt;doExecute()
  #38 /var/www/events/administrator/index.php(51): JApplicationCms-&gt;execute()
  #39 {main}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-12T08:40:28.743Z
Comments.Text: What do you mean by "we're now at 4.7.17 and 4.7.20"?  You can only be a one version ... or do you mean you are seeing the same problems on two different systems and one is 4.7.17, the other 4.7.20?
Comments.UserDisplayName: Aidan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-12T09:30:02.143Z
Comments.Text: Well, we could have had two installations, right? ;-) We don't, but the same thing happens in both 4.7.17 and after upgrading to 4.7.20.
Comments.UserDisplayName: thoni56
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-12T10:11:03.220Z
Comments.Text: What output do you get from cron? (you may need to change the cron entry to avoid discarding all the output).  I've seen these symptoms when the cron job runs out of memory
Comments.UserDisplayName: Aidan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-12T13:07:34.797Z
Comments.Text: What would I need to change to ensure I get all output? I do get a mail from the cronjob execution with a PHP notice, wouldn't any other output go into that mail too?
Comments.UserDisplayName: thoni56
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-13T08:45:00.833Z
Comments.Text: Output can go to STDOUT and STDERR and it is possible to redirect either or both to mail.  However, if you're getting the PHP notice then you should see any memory issues, so it's probably not that.
Comments.UserDisplayName: Aidan
Tags: <civimail><mailing>
Title: Scheduled mailings are started, but not finished, no messages sent unless "Run now"
ThreadText: # Scheduled mailings are started, but not finished, no messages sent unless "Run now"
  
  (Asked by: username_0 on 2017-06-12)
  
  I'm at a similar situation as in [this question](https://civicrm.stackexchange.com/questions/9457/mailings-are-started-but-not-sent-what-is-the-difference-between-a-scheduled-j?s=23|0.4802), which was a [bug](https://issues.civicrm.org/jira/browse/CRM-17968) that supposedly got fixed.
  
  Scheduled mailings get started by the cron job, but no mailings are sent and the job never finish.
  
  We had this at 4.7.17 and have just upgraded to 4.7.20 where it also exists.
  
  The job log indicate no error, there is nothing in the logs. BUT SEE UPDATE!
  
  Also running the job with "Run now" as the same user as the cron job sends and finishes the job. Running the same command as the cronjob (`php bin/cli.php -j <site> -u <user> -p <passw> -e Job -a execute`) from the servers command line does not send the mailings but the run is registered by the "Scheduled jobs" log.
  
  The `wget`method does not seem to work either, which indicates that it is not the same as [the other issue](https://civicrm.stackexchange.com/questions/9570/mailings-scheduler-fails-after-upgrade-to-4-7-1).
  
  UPDATE: There seems to be something related in the logs. It happens on the scheduling, so the timing is unrelated to the cronjobs, that's why I missed it.
  
  It's a missing field error (which might be [triggers or something else...](https://civicrm.stackexchange.com/questions/18951/no-such-field-card-type-but-exists)). I've pasted the complete log at the end of the question. The relevant part is probably this:
  
  ```
  [debug_info] =>
  INSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )
  SELECT ANY_VALUE(265), ANY_VALUE(i.contact_id), ANY_VALUE(i.phone_id)
  FROM       civicrm_contact contact_a
  INNER JOIN I_1253 i ON contact_a.id = i.contact_id
              INNER JOIN civicrm_email e ON e.id = i.email_id
             WHERE contact_a.is_deleted = 0
              GROUP BY e.email
  ORDER BY   MIN(i.contact_id), MIN(i.phone_id)
   [nativecode=1054 ** Unknown column 'i.email_id' in 'on clause']
  
  ```
  
  and this:
  
  ```
  #9 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-19, NULL, NULL, NULL, "1054 ** Unknown column 'i.email_id' in 'on clause'")
  #10 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError()
  #11 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/common.php(1216): DB_mysqli->simpleQuery("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #12 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php(2446): DB_common->query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #13 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php(1635): DB_DataObject->_query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #14 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php(362): DB_DataObject->query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #15 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php(1315): CRM_Core_DAO->query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...", TRUE)
  #16 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Mailing/BAO/Mailing.php(565): CRM_Core_DAO::executeQuery("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...", (Array:1))
  #17 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Mailing/BAO/Mailing.php(1791): CRM_Mailing_BAO_Mailing::getRecipients("1253", "265", TRUE, "1", "sms")
  #18 [internal function](): CRM_Mailing_BAO_Mailing::create((Array:54))
  #19 /var/www/events/administrator/components/com_civicrm/civicrm/api/v3/utils.php(1284): call_user_func_array((Array:2), (Array:1))
  #20 /var/www/events/administrator/components/com_civicrm/civicrm/api/v3/Mailing.php(70): _civicrm_api3_basic_create("CRM_Mailing_BAO_Mailing", (Array:54))
  #21 /var/www/events/administrator/components/com_civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_mailing_create((Array:53))
  #22 /var/www/events/administrator/components/com_civicrm/civicrm/Civi/API/Kernel.php(169): Civi\API\Provider\MagicFunctionProvider->invoke((Array:9))
  #23 /var/www/events/administrator/components/com_civicrm/civicrm/Civi/API/Kernel.php(100): Civi\API\Kernel->runRequest((Array:7))
  #24 /var/www/events/administrator/components/com_civicrm/civicrm/api/api.php(23): Civi\API\Kernel->runSafe("Mailing", "create", (Array:53), NULL)
  #25 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Utils/REST.php(404): civicrm_api("Mailing", "create", (Array:53))
  
  ```
  
  But if this happens so that the cronjob can't find the mailing, how can "Run now" do that?
  
  And what field in which table is it that's missing? My SQL is a bit rusty...
  
  How can I repair it?
  
  Here's the complete log:
  
  ```
  Jun 15 10:43:40  [info] $Fatal Error Details = Array
  (
      [callback] => Array
          (
              [0] => CRM_Core_Error
              [1] => exceptionHandler
          )
      [code] => -19
      [message] => DB Error: no such field
      [mode] => 16
      [debug_info] =>
  INSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )
  SELECT ANY_VALUE(265), ANY_VALUE(i.contact_id), ANY_VALUE(i.phone_id)
  FROM       civicrm_contact contact_a
  INNER JOIN I_1253 i ON contact_a.id = i.contact_id
              INNER JOIN civicrm_email e ON e.id = i.email_id
             WHERE contact_a.is_deleted = 0
              GROUP BY e.email
  ORDER BY   MIN(i.contact_id), MIN(i.phone_id)
   [nativecode=1054 ** Unknown column 'i.email_id' in 'on clause']
      [type] => DB_Error
      [user_info] =>
  INSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )
  SELECT ANY_VALUE(265), ANY_VALUE(i.contact_id), ANY_VALUE(i.phone_id)
  FROM       civicrm_contact contact_a
  INNER JOIN I_1253 i ON contact_a.id = i.contact_id
              INNER JOIN civicrm_email e ON e.id = i.email_id
             WHERE contact_a.is_deleted = 0
              GROUP BY e.email
  ORDER BY   MIN(i.contact_id), MIN(i.phone_id)
   [nativecode=1054 ** Unknown column 'i.email_id' in 'on clause']
      [to_string] => [db_error: message="DB Error: no such field" code=-19 mode=callback callback=CRM_Core_Error::exceptionHandler prefix="" info="
  INSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )
  SELECT ANY_VALUE(265), ANY_VALUE(i.contact_id), ANY_VALUE(i.phone_id)
  FROM       civicrm_contact contact_a
  INNER JOIN I_1253 i ON contact_a.id = i.contact_id
              INNER JOIN civicrm_email e ON e.id = i.email_id
             WHERE contact_a.is_deleted = 0
              GROUP BY e.email
  ORDER BY   MIN(i.contact_id), MIN(i.phone_id)
   [nativecode=1054 ** Unknown column 'i.email_id' in 'on clause']"]
  )
  
  Jun 15 10:43:40  [info] $backTrace = #0 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/Error.php(944): CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 [internal function](): CRM_Core_Error::exceptionHandler(Object(DB_Error))
  #2 /var/www/events/administrator/components/com_civicrm/civicrm/packages/PEAR.php(921): call_user_func((Array:2), Object(DB_Error))
  #3 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB.php(985): PEAR_Error->__construct("DB Error: no such field", -19, 16, (Array:2), "\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #4 /var/www/events/administrator/components/com_civicrm/civicrm/packages/PEAR.php(575): DB_Error->__construct(-19, 16, (Array:2), "\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #5 [internal function](): PEAR->_raiseError(Object(DB_mysqli), NULL, -19, NULL, NULL, "\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...", "DB_Error", TRUE)
  #6 /var/www/events/administrator/components/com_civicrm/civicrm/packages/PEAR.php(224): call_user_func_array((Array:2), (Array:8))
  #7 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/common.php(1905): PEAR->__call("raiseError", (Array:7))
  #8 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -19, NULL, NULL, "\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...", "DB_Error", TRUE)
  #9 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-19, NULL, NULL, NULL, "1054 ** Unknown column 'i.email_id' in 'on clause'")
  #10 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError()
  #11 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/common.php(1216): DB_mysqli->simpleQuery("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #12 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php(2446): DB_common->query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #13 /var/www/events/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php(1635): DB_DataObject->_query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #14 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php(362): DB_DataObject->query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...")
  #15 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php(1315): CRM_Core_DAO->query("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...", TRUE)
  #16 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Mailing/BAO/Mailing.php(565): CRM_Core_DAO::executeQuery("\nINSERT INTO civicrm_mailing_recipients ( mailing_id, contact_id, phone_id )...", (Array:1))
  #17 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Mailing/BAO/Mailing.php(1791): CRM_Mailing_BAO_Mailing::getRecipients("1253", "265", TRUE, "1", "sms")
  #18 [internal function](): CRM_Mailing_BAO_Mailing::create((Array:54))
  #19 /var/www/events/administrator/components/com_civicrm/civicrm/api/v3/utils.php(1284): call_user_func_array((Array:2), (Array:1))
  #20 /var/www/events/administrator/components/com_civicrm/civicrm/api/v3/Mailing.php(70): _civicrm_api3_basic_create("CRM_Mailing_BAO_Mailing", (Array:54))
  #21 /var/www/events/administrator/components/com_civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_mailing_create((Array:53))
  #22 /var/www/events/administrator/components/com_civicrm/civicrm/Civi/API/Kernel.php(169): Civi\API\Provider\MagicFunctionProvider->invoke((Array:9))
  #23 /var/www/events/administrator/components/com_civicrm/civicrm/Civi/API/Kernel.php(100): Civi\API\Kernel->runRequest((Array:7))
  #24 /var/www/events/administrator/components/com_civicrm/civicrm/api/api.php(23): Civi\API\Kernel->runSafe("Mailing", "create", (Array:53), NULL)
  #25 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Utils/REST.php(404): civicrm_api("Mailing", "create", (Array:53))
  #26 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Utils/REST.php(641): CRM_Utils_REST::process((Array:3), (Array:51))
  #27 [internal function](): CRM_Utils_REST::ajax()
  #28 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(276): call_user_func((Array:2))
  #29 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:12))
  #30 /var/www/events/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3))
  #31 /var/www/events/administrator/components/com_civicrm/civicrm.php(121): CRM_Core_Invoke::invoke((Array:3))
  #32 /var/www/events/administrator/components/com_civicrm/civicrm.php(40): civicrm_invoke()
  #33 /var/www/events/libraries/cms/component/helper.php(394): require_once("/var/www/events/administrator/components/com_civicrm/civicrm.php")
  #34 /var/www/events/libraries/cms/component/helper.php(369): JComponentHelper::executeComponent("/var/www/events/administrator/components/com_civicrm/civicrm.php")
  #35 /var/www/events/libraries/cms/application/administrator.php(98): JComponentHelper::renderComponent("com_civicrm")
  #36 /var/www/events/libraries/cms/application/administrator.php(156): JApplicationAdministrator->dispatch()
  #37 /var/www/events/libraries/cms/application/cms.php(265): JApplicationAdministrator->doExecute()
  #38 /var/www/events/administrator/index.php(51): JApplicationCms->execute()
  #39 {main}
  
  ```
  
  **Tags:** civimail, mailing
  
  > **Comments:**
  > **username_1**: What do you mean by "we're now at 4.7.17 and 4.7.20"?  You can only be a one version ... or do you mean you are seeing the same problems on two different systems and one is 4.7.17, the other 4.7.20?  
  > **username_0**: Well, we could have had two installations, right? ;-) We don't, but the same thing happens in both 4.7.17 and after upgrading to 4.7.20.  
  > **username_1**: What output do you get from cron? (you may need to change the cron entry to avoid discarding all the output).  I've seen these symptoms when the cron job runs out of memory  
  > **username_0**: What would I need to change to ensure I get all output? I do get a mail from the cronjob execution with a PHP notice, wouldn't any other output go into that mail too?  
  > **username_1**: Output can go to STDOUT and STDERR and it is possible to redirect either or both to mail.  However, if you're getting the PHP notice then you should see any memory issues, so it's probably not that.  
  
  ---
  
  ## 0 answers
  
  