Answers.Body: <p>It's not easy to get it working properly indeed.</p>
  
  <p>Sending a "normal" email and civimails follow a different path. The former is simple: you call the "send an email" you configured (usually the mail() function, but can be configured, eg to use smtp directly), wait until it's done and that's it.</p>
  
  <p>This doesn't scale and if you aim, like civimail does, at sending lots of emails, you need to queue these emails, possibly split them in separate batches and have a cronjob that process them in the background to send these emails</p>
  
  <p>And were it becomes even more complicated is that you have a lot of different ways to run that cronjob, because civicrm aims at serving a lot of different configurations.... and each have lots of opportunities to have something not working.</p>
  
  <p>As you are using joomla, the "common solution" we use (drush) isn't an option. You do not detail your system, do you:</p>
  
  <ul>
  <li>have access to the command line (ssh)</li>
  <li>can set up cronjobs</li>
  <li>have php-cli installed and with the same configuration as the php used for your server?</li>
  </ul>
  
  <p>You haven't described enough how have configured CiviCRM. If this is not how you are using it, could edit your question and add these details and what you get if you run</p>
  
  <pre><code>path/to/php /path/to/civcrm/module/bin/cli.php -s site -u user -p password -e Job -a execute
  </code></pre>
  
  <p>As described: <a href="https://wiki.civicrm.org/confluence/display/CRMDOC/Managing+Scheduled+Jobs" rel="nofollow noreferrer">https://wiki.civicrm.org/confluence/display/CRMDOC/Managing+Scheduled+Jobs</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-18T22:00:10.413Z
Answers.Text: The scheduled job works, cron is setup and working 100%.  it shows in the scheduled job logs that it ran sucessfully, it just never actually RUNS the cron job!  I just don't know where to look from here to see what is blocking the email from going out.  ALSO - if i go into a contact directly in Civi and send them an email, it does send just fine, so Civi sends email from any other module, JUST the civimail doesn't work
Answers.UserDisplayName: John Shoff
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-03T06:52:02.110Z
Answers.LastActivityDate: 2017-05-17T15:19:04.527Z
Answers.LastEditDate: 2017-05-17T15:19:04.527Z
Answers.UserDisplayName: Xavier
Answers.Body: <p>I had this same problem working through setting up a new CiviCRM instance.  There was indeed a lot of set up, but I wanted to share some of it.</p>
  <h3>TIL Cron isn't enabled by default</h3>
  <p>Cron does not execute in the same context as the shell testing job.execute.  For me, I was running <code>cv api --user=admin job.execute</code> and it was working fine.  However, adding that to crontab did not execute the task.  To get cron running, I had to do the following:</p>
  <ol>
  <li><code>sudo service cron status</code> told me cron wasn't even executing!  <code>sudo service cron start</code> solved that</li>
  <li>To view the cron logs, I uncommented the cron line <code>sudo vi /etc/rsyslog.d/50-default.conf</code></li>
  <li>To view cron executions <code>tail -f /var/log/cron.log</code></li>
  </ol>
  <h3>The job executes, but what is the result?</h3>
  <p>Now I knew the command was running, but what was it doing?  I modified the cron job to show me <code>crontab -e</code></p>
  <p><code>* * * * * /usr/local/bin/cv api --user=admin job.execute &gt; /tmp/cv.cron.log 2&gt;&amp;1</code></p>
  <p>Now I can see the failures, which was cv not finding civicrm.settings.php file.  This is where the context of cron differs from my shell.  I run <code>env</code> in my shell and compare it to cron's.  By creating a new cron job:</p>
  <p><code>* * * * * env &gt; /tmp/cron.env.log</code></p>
  <p><code>less /tmp/cron.env.log</code> after <code>tail -f /var/log/cron.log</code> to make sure it ran.  There's no environment!  My path is <code>/usr/bin:/bin</code>.  No wonder cv cannot find my site.</p>
  <h3>Change the current working directory &amp; Use absolute paths</h3>
  <p>I changed my cron job to change directory into the <code>/drupal/sites/default</code> folder and now my cron jobs show up.  My full crontab command:</p>
  <p><code>* * * * * cd /home/andy/git/drupal/sites/default &amp;&amp; /usr/local/bin/cv api --user=cron job.execute &gt; /tmp/cv.cron.log 2&gt;&amp;1</code></p>
  <p>I'm sure your paths will differ.  Now that I can see the json response I can remove the <code>&gt; /tmp/cv.cron.log 2&gt;&amp;1</code></p>
  <h3>TL;DR</h3>
  <p>cron needs to know where your files are.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-16T15:59:38.600Z
Answers.LastActivityDate: 2018-03-16T15:59:38.600Z
Answers.LastEditDate: 2020-06-17T09:00:50.810Z
Answers.UserDisplayName: Andy Gauge
Body: <p>I can send an email from any other area of Civi.  For example if I select a contact and send an individual email, it works...</p>
  
  <p>BUT CiviMail - IS DRIVING ME CRAZY!!!</p>
  
  <p>I am routing all email to spamexperts (using SMTP setting in Civi Admin) and again, it all works in other areas of the website, and even any other area of Civi itself.</p>
  
  <p>I've check and confirmed the CRON job runs, I am even running it manually again just to be sure.  The CRON job for "send mailings" shows in the log that there is no errors, and everything is "sent" but it doesn't ever send any emails.</p>
  
  <p>If I check the spamexperts delivery logs, I can see all my other emails going through that I send from other areas of Civi, but there is NO record of the civimail mailings even getting to spamexperts.</p>
  
  <p>I am at a total loss, any ideas anyone?  I owe you big time if you can point me in the right direction!</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-04-28T07:42:52.797Z
Comments.Text: Just to be clear, when you're 'running it manually' - do you mean running something from the command line, or going to `Administer > System Settings > Scheduled Jobs`, find `Send Scheduled Mailings` then `more > Execute Now` ?    I have seen situations where `Execute Now` works but running via cron fails because of permissions.
Comments.UserDisplayName: Aidan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-02T04:25:11.160Z
Comments.Text: Does your mailing report show the correct number of mails sent?  What does your CiviCRM log (in ConfigAndLog directory) show, if anything?
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-18T21:58:32.537Z
Comments.Text: I can run manually via scheduled jobs, and it "says" it has run properly.  ALSO - the CRON does work, there was an issue with Joomla 3.7.0 that messed up cron jobs, but 3.7.1 did fix that.   So all my cron jobs fire off and run, BUT the email never gets to the recipient.
Comments.UserDisplayName: John Shoff
Tags: <civimail><joomla>
Title: CiviMail not sending emails - Joomla 3.6 or 3.7 & Civi 4.7.18
ThreadText: # CiviMail not sending emails - Joomla 3.6 or 3.7 & Civi 4.7.18
  
  (Asked by: username_0 on 2017-04-28)
  
  I can send an email from any other area of Civi. For example if I select a contact and send an individual email, it works...
  
  BUT CiviMail - IS DRIVING ME CRAZY!!!
  
  I am routing all email to spamexperts (using SMTP setting in Civi Admin) and again, it all works in other areas of the website, and even any other area of Civi itself.
  
  I've check and confirmed the CRON job runs, I am even running it manually again just to be sure. The CRON job for "send mailings" shows in the log that there is no errors, and everything is "sent" but it doesn't ever send any emails.
  
  If I check the spamexperts delivery logs, I can see all my other emails going through that I send from other areas of Civi, but there is NO record of the civimail mailings even getting to spamexperts.
  
  I am at a total loss, any ideas anyone? I owe you big time if you can point me in the right direction!
  
  **Tags:** civimail, joomla
  
  > **Comments:**
  > **username_1**: Just to be clear, when you're 'running it manually' - do you mean running something from the command line, or going to `Administer > System Settings > Scheduled Jobs`, find `Send Scheduled Mailings` then `more > Execute Now` ?    I have seen situations where `Execute Now` works but running via cron fails because of permissions.  
  > **username_2**: Does your mailing report show the correct number of mails sent?  What does your CiviCRM log (in ConfigAndLog directory) show, if anything?  
  > **username_0**: I can run manually via scheduled jobs, and it "says" it has run properly.  ALSO - the CRON does work, there was an issue with Joomla 3.7.0 that messed up cron jobs, but 3.7.1 did fix that.   So all my cron jobs fire off and run, BUT the email never gets to the recipient.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2017-05-03. Score: 1
  
  It's not easy to get it working properly indeed.
  Sending a "normal" email and civimails follow a different path. The former is simple: you call the "send an email" you configured (usually the mail() function, but can be configured, eg to use smtp directly), wait until it's done and that's it.
  This doesn't scale and if you aim, like civimail does, at sending lots of emails, you need to queue these emails, possibly split them in separate batches and have a cronjob that process them in the background to send these emails
  And were it becomes even more complicated is that you have a lot of different ways to run that cronjob, because civicrm aims at serving a lot of different configurations.... and each have lots of opportunities to have something not working.
  As you are using joomla, the "common solution" we use (drush) isn't an option. You do not detail your system, do you:
  
  have access to the command line (ssh)
  can set up cronjobs
  have php-cli installed and with the same configuration as the php used for your server?
  
  You haven't described enough how have configured CiviCRM. If this is not how you are using it, could edit your question and add these details and what you get if you run
  path/to/php /path/to/civcrm/module/bin/cli.php -s site -u user -p password -e Job -a execute
  
  As described: https://wiki.civicrm.org/confluence/display/CRMDOC/Managing+Scheduled+Jobs
  
  > **Comments:**
  > **username_0**: The scheduled job works, cron is setup and working 100%.  it shows in the scheduled job logs that it ran sucessfully, it just never actually RUNS the cron job!  I just don't know where to look from here to see what is blocking the email from going out.  ALSO - if i go into a contact directly in Civi and send them an email, it does send just fine, so Civi sends email from any other module, JUST the civimail doesn't work  
  
  ---
  
  ### Answer by username_4 on 2018-03-16. Score: 0
  
  I had this same problem working through setting up a new CiviCRM instance. There was indeed a lot of set up, but I wanted to share some of it.
  
  ### TIL Cron isn't enabled by default
  
  Cron does not execute in the same context as the shell testing job.execute. For me, I was running `cv api --user=admin job.execute` and it was working fine. However, adding that to crontab did not execute the task. To get cron running, I had to do the following:
  
  1. `sudo service cron status` told me cron wasn't even executing! `sudo service cron start` solved that
  2. To view the cron logs, I uncommented the cron line `sudo vi /etc/rsyslog.d/50-default.conf`
  3. To view cron executions `tail -f /var/log/cron.log`
  
  ### The job executes, but what is the result?
  
  Now I knew the command was running, but what was it doing? I modified the cron job to show me `crontab -e`
  
  `* * * * * /usr/local/bin/cv api --user=admin job.execute > /tmp/cv.cron.log 2>&1`
  
  Now I can see the failures, which was cv not finding civicrm.settings.php file. This is where the context of cron differs from my shell. I run `env` in my shell and compare it to cron's. By creating a new cron job:
  
  `* * * * * env > /tmp/cron.env.log`
  
  `less /tmp/cron.env.log` after `tail -f /var/log/cron.log` to make sure it ran. There's no environment! My path is `/usr/bin:/bin`. No wonder cv cannot find my site.
  
  ### Change the current working directory & Use absolute paths
  
  I changed my cron job to change directory into the `/drupal/sites/default` folder and now my cron jobs show up. My full crontab command:
  
  `* * * * * cd /home/andy/git/drupal/sites/default && /usr/local/bin/cv api --user=cron job.execute > /tmp/cv.cron.log 2>&1`
  
  I'm sure your paths will differ. Now that I can see the json response I can remove the `> /tmp/cv.cron.log 2>&1`
  
  ### TL;DR
  
  cron needs to know where your files are.
  
  
  ---
  
  