Details
Description
Using curl or wget to run civimail.cronjob.php works fine, but it's more efficient to do mailings using the php command line program. But in Drupal 7 there are issues with this. First it gives an error that says:
"Usage: Please define CIVICRM_CONFDIR in settings_location.php at the top level civicrm directory"
But this is fixed by setting CIVICRM_CONFDIR in civicrm.settings.php. But then when I run it again I get this error:
"<br />Sorry, could not able to load drupal bootstrap."
I found this error message getting printed in CRM/Utils/System/Drupal.php. It looks like Drupal isn't getting bootstrapped correctly, I think because bootstrapping is slightly different in Drupal 7 than it was in Drupal 6. Adding this drupal_override_server_variables() line fixes this (see attached civimail.diff for the patch):
// load drupal bootstrap
chdir($cmsPath);
define('DRUPAL_ROOT', $cmsPath);
require_once 'includes/bootstrap.inc';
drupal_override_server_variables(array('url' => CIVICRM_UF_BASEURL));
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
Now civimail.cronjob.php runs without errors from the php cli, and it sends out mailings. Except the emails are blank! An email sent using the cli looks like this:
Delivered-To: micahflee@gmail.com
Received: by 10.180.99.230 with SMTP id et6cs31125wib;
Wed, 26 Oct 2011 12:14:07 -0700 (PDT)
Received: by 10.42.157.135 with SMTP id d7mr53148762icx.19.1319656446484;
Wed, 26 Oct 2011 12:14:06 -0700 (PDT)
Return-Path: <b.120.172.ba8b7f405cc80923@contact.eff.org>
Received: from sh.uas.coop (civismtp.uas.coop. [67.212.170.242])
by mx.google.com with ESMTP id a6si1391326icw.70.2011.10.26.12.14.06;
Wed, 26 Oct 2011 12:14:06 -0700 (PDT)
Received-SPF: pass (google.com: domain of b.120.172.ba8b7f405cc80923@contact.eff.org designates 67.212.170.242 as permitted sender) client-ip=67.212.170.242;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of b.120.172.ba8b7f405cc80923@contact.eff.org designates 67.212.170.242 as permitted sender) smtp.mail=b.120.172.ba8b7f405cc80923@contact.eff.org
Received: from supporters.eff.org (HELO localhost) (69.50.232.54)
(smtp-auth username eff, mechanism cram-md5)
by sh.uas.coop (qpsmtpd/0.40) with ESMTPA; Wed, 26 Oct 2011 13:05:08 -0500
MIME-Version: 1.0
Reply-To: "Electronic Frontier Foundation" <membership@eff.org>
From: "Electronic Frontier Foundation" <membership@eff.org>
Subject: This is a test mailing
List-Unsubscribe: <u.120.172.ba8b7f405cc80923@contact.eff.org>
To: Micah Lee <micahflee@gmail.com>
Precedence: bulk
X-CiviMail-Bounce: b.120.172.ba8b7f405cc80923@contact.eff.org
Date: Wed, 26 Oct 2011 12:14:05 -0700
Message-Id: <20111026180508.3B015124C0BD@sh.uas.coop>
It looks like the body just gets entirely skipped or something, but I haven't had time to figure out why. Maybe Drupal isn't actually getting bootstrapped correctly, but it's just not triggering the error? For now we will continue to use curl to send the mailings until we can figure this out.