Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Email Queue 2.0


aodfan

Recommended Posts

Warning: main(includes/configuration_cache_read.php): failed to open stream: No such file or directory in /home/wspilo2/public_html/catalog/admin/email_batch_send.php on line 3

 

Warning: main(includes/configuration_cache_read.php): failed to open stream: No such file or directory in /home/wspilo2/public_html/catalog/admin/email_batch_send.php on line 3

 

Fatal error: main(): Failed opening required 'includes/configuration_cache_read.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/wspilo2/public_html/catalog/admin/email_batch_send.php on line 3

Hi Amanda,

 

I seem to be getting the following problem when I run cron manager on email_batch_send.php or when I call it up in my browser. I can't seem to get the file to work right. It looks like I don't have the file it's calling configuration_cache_read.php

 

Thanks for any help.

 

Best regards

 

Rob

Link to comment
Share on other sites

  • Replies 68
  • Created
  • Last Reply

Top Posters In This Topic

So basically change this code :

 

	function send($newsletter_id) {
  $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");

  $mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));
  $mimemessage->add_text($this->content);
  $mimemessage->build_message();
  while ($mail = tep_db_fetch_array($mail_query)) {
	$mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title);
  }

  $newsletter_id = tep_db_prepare_input($newsletter_id);
  tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'");
}

 

into this code :

 

	function send($newsletter_id) {
  $mail_query = tep_db_query("select customers_firstname, 
									 customers_lastname, 
									 customers_email_address 
							  from " . TABLE_CUSTOMERS . " 
							  where customers_newsletter = '1'");

  while ($mail = tep_db_fetch_array($mail_query)) {
	if (USE_EMAIL_QUEUE == 'true') { 
	  tep_store_mail($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], 
					 $mail['customers_email_address'], 
					 $this->title,
					 $this->content, 
					 STORE_OWNER, 
					 STORE_OWNER_EMAIL_ADDRESS);
	} else {
	  tep_mail($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], 
			   $mail['customers_email_address'], 
			   $this->title,
			   $this->content, 
			   STORE_OWNER, 
			   STORE_OWNER_EMAIL_ADDRESS);
	}
  }

  $newsletter_id = tep_db_prepare_input($newsletter_id);
  tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'");
}

	function send($newsletter_id) {
  global $HTTP_POST_VARS;

  $audience = array();

  if (isset($HTTP_POST_VARS['global']) && ($HTTP_POST_VARS['global'] == 'true')) {
	$products_query = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id");
	while ($products = tep_db_fetch_array($products_query)) {
	  $audience[$products['customers_id']] = array('firstname' => $products['customers_firstname'],
												   'lastname' => $products['customers_lastname'],
												   'email_address' => $products['customers_email_address']);
	}

	$customers_query = tep_db_query("select c.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_INFO . " ci where c.customers_id = ci.customers_info_id and ci.global_product_notifications = '1'");
	while ($customers = tep_db_fetch_array($customers_query)) {
	  $audience[$customers['customers_id']] = array('firstname' => $customers['customers_firstname'],
													'lastname' => $customers['customers_lastname'],
													'email_address' => $customers['customers_email_address']);
	}
  } else {
	$chosen = $HTTP_POST_VARS['chosen'];

	$ids = implode(',', $chosen);

	$products_query = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id and pn.products_id in (" . $ids . ")");
	while ($products = tep_db_fetch_array($products_query)) {
	  $audience[$products['customers_id']] = array('firstname' => $products['customers_firstname'],
												   'lastname' => $products['customers_lastname'],
												   'email_address' => $products['customers_email_address']);
	}

	$customers_query = tep_db_query("select c.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_INFO . " ci where c.customers_id = ci.customers_info_id and ci.global_product_notifications = '1'");
	while ($customers = tep_db_fetch_array($customers_query)) {
	  $audience[$customers['customers_id']] = array('firstname' => $customers['customers_firstname'],
													'lastname' => $customers['customers_lastname'],
													'email_address' => $customers['customers_email_address']);
	}
  }

while ($mail = $customers) {
if (USE_EMAIL_QUEUE == 'true') { 
tep_store_mail($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], 
$mail['customers_email_address'], 
$this->title,
$this->content, 
STORE_OWNER, 
STORE_OWNER_EMAIL_ADDRESS);
} else {
tep_mail($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], 
$mail['customers_email_address'], 
$this->title,
$this->content, 
STORE_OWNER, 
STORE_OWNER_EMAIL_ADDRESS);
}
}


  $newsletter_id = tep_db_prepare_input($newsletter_id);
  tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'");
}
 }
?>

I tried to modify the code in product_notification.php in modules and haven't had much success. My numerous attempts actually led to the server overloading as a process would not terminate, constantly creating records with no customer specified (the result of $mail = $audience)

 

Any how thanks for any help provided to adapt it for the product_notification.php

 

Best regards

 

Rob

Link to comment
Share on other sites

	function send($newsletter_id) {
  global $HTTP_POST_VARS;

  $audience = array();

  if (isset($HTTP_POST_VARS['global']) && ($HTTP_POST_VARS['global'] == 'true')) {
	$products_query = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id");
	while ($products = tep_db_fetch_array($products_query)) {
	  $audience[$products['customers_id']] = array('firstname' => $products['customers_firstname'],
												   'lastname' => $products['customers_lastname'],
												   'email_address' => $products['customers_email_address']);
	}

	$customers_query = tep_db_query("select c.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_INFO . " ci where c.customers_id = ci.customers_info_id and ci.global_product_notifications = '1'");
	while ($customers = tep_db_fetch_array($customers_query)) {
	  $audience[$customers['customers_id']] = array('firstname' => $customers['customers_firstname'],
													'lastname' => $customers['customers_lastname'],
													'email_address' => $customers['customers_email_address']);
	}
  } else {
	$chosen = $HTTP_POST_VARS['chosen'];

	$ids = implode(',', $chosen);

	$products_query = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id and pn.products_id in (" . $ids . ")");
	while ($products = tep_db_fetch_array($products_query)) {
	  $audience[$products['customers_id']] = array('firstname' => $products['customers_firstname'],
												   'lastname' => $products['customers_lastname'],
												   'email_address' => $products['customers_email_address']);
	}

	$customers_query = tep_db_query("select c.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_INFO . " ci where c.customers_id = ci.customers_info_id and ci.global_product_notifications = '1'");
	while ($customers = tep_db_fetch_array($customers_query)) {
	  $audience[$customers['customers_id']] = array('firstname' => $customers['customers_firstname'],
													'lastname' => $customers['customers_lastname'],
													'email_address' => $customers['customers_email_address']);
	}
  }

while ($mail = $customers) {
if (USE_EMAIL_QUEUE == 'true') { 
tep_store_mail($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], 
$mail['customers_email_address'], 
$this->title,
$this->content, 
STORE_OWNER, 
STORE_OWNER_EMAIL_ADDRESS);
} else {
tep_mail($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], 
$mail['customers_email_address'], 
$this->title,
$this->content, 
STORE_OWNER, 
STORE_OWNER_EMAIL_ADDRESS);
}
}
  $newsletter_id = tep_db_prepare_input($newsletter_id);
  tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'");
}
 }
?>

I tried to modify the code in product_notification.php in modules and haven't had much success. My numerous attempts actually led to the server overloading as a process would not terminate, constantly creating records with no customer specified (the result of $mail = $audience)

 

Any how thanks for any help provided to adapt it for the product_notification.php

 

Best regards

 

Rob

 

 

well, in notifications, you need to concentrate on where the email is made and send, the rest is irrelevant.

 

so you have this code :

 

$mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));

 

// MaxiDVD Added Line For WYSIWYG HTML Area: BOF (Send TEXT Product Notifications v1.7 when WYSIWYG Disabled)

if (HTML_AREA_WYSIWYG_DISABLE_NEWSLETTER == 'Disable') {

$mimemessage->add_text($this->content);

} else {

$mimemessage->add_html($this->content);

// MaxiDVD Added Line For WYSIWYG HTML Area: EOF (Send TEXT Product Notifications v1.7 when WYSIWYG Enabled)

}

 

$mimemessage->build_message();

 

reset($audience);

while (list($key, $value) = each ($audience)) {

$mimemessage->send($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], '', EMAIL_FROM, $this->title);

}

 

which makes the email (in the typical crappy admin way) and sends it.

 

 

we change all of that to :

 

 

 

reset($audience);

while (list($key, $value) = each ($audience)) {

if (USE_EMAIL_QUEUE == 'true') {

tep_store_mail($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], $this->title,$this->content, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

} else {

tep_mail($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], $this->title,$this->content, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

}

}

Treasurer MFC

Link to comment
Share on other sites

well, in notifications, you need to concentrate on where the email is made and send, the rest is irrelevant.

 

so you have this code :

 

$mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));

 

// MaxiDVD Added Line For WYSIWYG HTML Area: BOF (Send TEXT Product Notifications v1.7 when WYSIWYG Disabled)

if (HTML_AREA_WYSIWYG_DISABLE_NEWSLETTER == 'Disable') {

$mimemessage->add_text($this->content);

} else {

$mimemessage->add_html($this->content);

// MaxiDVD Added Line For WYSIWYG HTML Area: EOF (Send TEXT Product Notifications v1.7 when WYSIWYG Enabled)

}

 

$mimemessage->build_message();

 

reset($audience);

while (list($key, $value) = each ($audience)) {

$mimemessage->send($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], '', EMAIL_FROM, $this->title);

}

 

which makes the email (in the typical crappy admin way) and sends it.

we change all of that to :

reset($audience);

while (list($key, $value) = each ($audience)) {

if (USE_EMAIL_QUEUE == 'true') {

tep_store_mail($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], $this->title,$this->content, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

} else {

tep_mail($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], $this->title,$this->content, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

}

}

 

Thanks again. Great support! Following copied code, as the number of brackets required was confusing then for a minute.

reset($audience);
while (list($key, $value) = each ($audience)) {
if (USE_EMAIL_QUEUE == 'true') { 
tep_store_mail($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], $this->title,$this->content, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
} else {
tep_mail($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], $this->title,$this->content, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
}
}
}
}
?>

Link to comment
Share on other sites

Everthing is working great with regards to product_notification.php and newsletter.php in /admin/includes/modules

 

I now get the desired results, i.e. all emails sent appear in the email queue, waiting for the email_batch_send.php to be run.

 

So I call up home/catalog/admin/email_batch_send.php in my browser and it runs fine, no hickups apparently, nothing displayed either, blank window.

 

I then go to email queue in tools and see that the emails have been updated to send. However, I haven't received a test email. So it doesn't look like email_batch_send.php has actually sent mails, but rather just updated the status of those in queue to send.

 

Am I missing something?

 

Here is email_batch_send.php file

 

<?php
require('includes/configure.php');

if (HOLD_EMAIL_QUEUE == 'true') {} else {
 require(DIR_WS_INCLUDES . 'filenames.php');
 require(DIR_WS_INCLUDES . 'database_tables.php');
 require(DIR_WS_FUNCTIONS . 'database.php');
 tep_db_connect() or die('We are currently unavailable due to Maintenance..');
 require(DIR_WS_FUNCTIONS . 'general.php');
 require(DIR_WS_CLASSES . 'mime.php');
 require(DIR_WS_CLASSES . 'email.php');
 $email_query = tep_db_query("select * from email_batch where (send is null or send = '') and (hold is null or hold = '')  ");
 while ($email = mysql_fetch_array($email_query)) {
define('CHARSET', $email['charset']);
$email['text'] = str_replace("\n", '<br>', $email['text']);
tep_mail(
		 $email['to_name'], 
		 $email['to_address'], 
		 $email['subject'],
		 $email['text'],
		 $email['from_name'], 
		 $email['from_address']);
tep_db_query("update email_batch set send = 'on', last_updated = now() where id = '" . $email['id']. "'");
 }
 mysql_free_result($email_query);
}
?>

Link to comment
Share on other sites

Everthing is working great with regards to product_notification.php and newsletter.php in /admin/includes/modules

 

I now get the desired results, i.e. all emails sent appear in the email queue, waiting for the email_batch_send.php to be run.

 

So I call up home/catalog/admin/email_batch_send.php in my browser and it runs fine, no hickups apparently, nothing displayed either, blank window.

 

I then go to email queue in tools and see that the emails have been updated to send. However, I haven't received a test email. So it doesn't look like email_batch_send.php has actually sent mails, but rather just updated the status of those in queue to send.

 

Am I missing something?

 

Here is email_batch_send.php file

 

<?php
require('includes/configure.php');

if (HOLD_EMAIL_QUEUE == 'true') {} else {
 require(DIR_WS_INCLUDES . 'filenames.php');
 require(DIR_WS_INCLUDES . 'database_tables.php');
 require(DIR_WS_FUNCTIONS . 'database.php');
 tep_db_connect() or die('We are currently unavailable due to Maintenance..');
 require(DIR_WS_FUNCTIONS . 'general.php');
 require(DIR_WS_CLASSES . 'mime.php');
 require(DIR_WS_CLASSES . 'email.php');
 $email_query = tep_db_query("select * from email_batch where (send is null or send = '') and (hold is null or hold = '')  ");
 while ($email = mysql_fetch_array($email_query)) {
define('CHARSET', $email['charset']);
$email['text'] = str_replace("\n", '<br>', $email['text']);
tep_mail(
		 $email['to_name'], 
		 $email['to_address'], 
		 $email['subject'],
		 $email['text'],
		 $email['from_name'], 
		 $email['from_address']);
tep_db_query("update email_batch set send = 'on', last_updated = now() where id = '" . $email['id']. "'");
 }
 mysql_free_result($email_query);
}
?>

 

 

suggest you alter it a little so you can see what it does or doesn't do like:

 

<?php

require('includes/configure.php');

 

if (HOLD_EMAIL_QUEUE == 'true') {} else {

echo 'Sending Emails from the Queue.....' . "\n";

require(DIR_WS_INCLUDES . 'filenames.php');

require(DIR_WS_INCLUDES . 'database_tables.php');

require(DIR_WS_FUNCTIONS . 'database.php');

tep_db_connect() or die('We are currently unavailable due to Maintenance..');

require(DIR_WS_FUNCTIONS . 'general.php');

require(DIR_WS_CLASSES . 'mime.php');

require(DIR_WS_CLASSES . 'email.php');

$email_query = tep_db_query("select * from email_batch where (send is null or send = '') and (hold is null or hold = '') ");

while ($email = mysql_fetch_array($email_query)) {

echo 'Sending...' . $email['id'];

define('CHARSET', $email['charset']);

$email['text'] = str_replace("\n", '<br>', $email['text']);

$send_result = tep_mail(

$email['to_name'],

$email['to_address'],

$email['subject'],

$email['text'],

$email['from_name'],

$email['from_address']);

echo 'result=[';

echo 'result=[';

if ($send_result) {

tep_db_query("update email_batch set send = 'on', last_updated = now() where id = '" . $email['id']. "'");

echo 'OK]'."\n";

} else {

echo 'ERROR]'."\n";

}

}

echo 'Done'."\n";

mysql_free_result($email_query);

}

?>

 

but make sure you alter the tep_mail function so it returns a result like :

 

change this line :

 

$message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject);

 

into this line :

 

return $message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject);

Treasurer MFC

Link to comment
Share on other sites

suggest you alter it a little so you can see what it does or doesn't do like:

 

<?php

require('includes/configure.php');

 

if (HOLD_EMAIL_QUEUE == 'true') {} else {

echo 'Sending Emails from the Queue.....' . "\n";

require(DIR_WS_INCLUDES . 'filenames.php');

require(DIR_WS_INCLUDES . 'database_tables.php');

require(DIR_WS_FUNCTIONS . 'database.php');

tep_db_connect() or die('We are currently unavailable due to Maintenance..');

require(DIR_WS_FUNCTIONS . 'general.php');

require(DIR_WS_CLASSES . 'mime.php');

require(DIR_WS_CLASSES . 'email.php');

$email_query = tep_db_query("select * from email_batch where (send is null or send = '') and (hold is null or hold = '') ");

while ($email = mysql_fetch_array($email_query)) {

echo 'Sending...' . $email['id'];

define('CHARSET', $email['charset']);

$email['text'] = str_replace("\n", '<br>', $email['text']);

$send_result = tep_mail(

$email['to_name'],

$email['to_address'],

$email['subject'],

$email['text'],

$email['from_name'],

$email['from_address']);

echo 'result=[';

echo 'result=[';

if ($send_result) {

tep_db_query("update email_batch set send = 'on', last_updated = now() where id = '" . $email['id']. "'");

echo 'OK]'."\n";

} else {

echo 'ERROR]'."\n";

}

}

echo 'Done'."\n";

mysql_free_result($email_query);

}

?>

 

but make sure you alter the tep_mail function so it returns a result like :

 

change this line :

 

$message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject);

 

into this line :

 

return $message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject);

 

I get the following message in the email_batch_send.php window

 

Sending Emails from the Queue..... Sending...1result=[result=[ERROR] Done

 

Now the mail status is not being updated to sent like before.

Link to comment
Share on other sites

I get the following message in the email_batch_send.php window

 

Sending Emails from the Queue..... Sending...1result=[result=[ERROR] Done

 

Now the mail status is not being updated to sent like before.

 

well that means that tep_mail returns false when trying to send email with id=1.

 

have you ever send anything this way?

 

if you simply press "send" in the queue, does it send then ?

Treasurer MFC

Link to comment
Share on other sites

well that means that tep_mail returns false when trying to send email with id=1.

 

have you ever send anything this way?

 

if you simply press "send" in the queue, does it send then ?

Yes, if I press send button, the mail is sent and received.

 

If I create a mailing, the emails are stored in the queue. So tep_store_mail is working. The icons that appear next to the email are released (left pointing arrow) and sheduled (clock).

 

Then I run email_batch_send.php and I get that error. And nothing happens to the status of the email.

 

So I replaced the email_batch_send.php with the original one you provided in the contrib. I call up home/catalog/admin/email_batch_send.php in my browser, which shows blank.

 

Then I go to the email queue and the email has changed to Realeased (left pointing arrow) and Send (Green Check), but I don't receive the email in my mail box. Am I suppose to send the emails manually with the Send button? or are they suppose to be sent when email_batch_send.php is run?

 

The goal is to have email_batch_send.php being run by cron job every 5-10mn

 

Best regards

 

Robert

 

PS Happy new year if I don't hear from you before.

Link to comment
Share on other sites

Yes, if I press send button, the mail is sent and received.

 

If I create a mailing, the emails are stored in the queue. So tep_store_mail is working. The icons that appear next to the email are released (left pointing arrow) and sheduled (clock).

 

Then I run email_batch_send.php and I get that error. And nothing happens to the status of the email.

 

So I replaced the email_batch_send.php with the original one you provided in the contrib. I call up home/catalog/admin/email_batch_send.php in my browser, which shows blank.

 

Then I go to the email queue and the email has changed to Realeased (left pointing arrow) and Send (Green Check), but I don't receive the email in my mail box. Am I suppose to send the emails manually with the Send button? or are they suppose to be sent when email_batch_send.php is run?

 

The goal is to have email_batch_send.php being run by cron job every 5-10mn

 

Best regards

 

Robert

 

PS Happy new year if I don't hear from you before.

 

well, I run it as a scheduled job also.

 

if you send function works, which uses the very same tep_mail function, then it must be the retrieval of the data.

 

try using this version, the very one I use now:

 

<?php

require('includes/configure.php');

require(DIR_WS_INCLUDES . 'filenames.php');

require(DIR_WS_INCLUDES . 'database_tables.php');

require(DIR_WS_FUNCTIONS . 'database.php');

tep_db_connect() or die('We are currently unavailable due to Maintenance..');

require(DIR_WS_FUNCTIONS . 'general.php');

require(DIR_WS_CLASSES . 'mime.php');

require(DIR_WS_CLASSES . 'email.php');

require ('includes/configuration_cache_read.php');

if (HOLD_EMAIL_QUEUE != 'true') {

echo 'Sending Emails from the Queue.....' . "\n";

$mail_qry = "select id,

charset,

to_name,

to_address,

subject,

text,

from_name,

from_address,

created

from email_batch

where (send is null or send = '') and

(hold is null or hold = '')

order by created asc

limit 5";

$email_query = tep_db_query($mail_qry);

while ($email = mysql_fetch_array($email_query)) {

echo 'Sending...' . $email['id'].' '.$email['to_name'].' '.$email['to_address']."\n";

define('CHARSET', $email['charset']);

$send_result = tep_mail(

$email['to_name'],

$email['to_address'],

$email['subject'],

$email['text'],

$email['from_name'],

$email['from_address']);

echo 'result=[';

if ($send_result) {

tep_db_query("update email_batch set send = 'on', last_updated = now() where id = '" . $email['id']. "'");

echo 'OK]'."\n";

} else {

echo 'ERROR]'."\n";

}

}

echo 'Done'."\n";

mysql_free_result($email_query);

}

?>

 

PS. do you have the configuration cache facility installed? that is, do you use/have includes/configuration_cache_read.php ?

Treasurer MFC

Link to comment
Share on other sites

well, I run it as a scheduled job also.

 

if you send function works, which uses the very same tep_mail function, then it must be the retrieval of the data.

 

try using this version, the very one I use now:

 

<?php

require('includes/configure.php');

require(DIR_WS_INCLUDES . 'filenames.php');

require(DIR_WS_INCLUDES . 'database_tables.php');

require(DIR_WS_FUNCTIONS . 'database.php');

tep_db_connect() or die('We are currently unavailable due to Maintenance..');

require(DIR_WS_FUNCTIONS . 'general.php');

require(DIR_WS_CLASSES . 'mime.php');

require(DIR_WS_CLASSES . 'email.php');

require ('includes/configuration_cache_read.php');

if (HOLD_EMAIL_QUEUE != 'true') {

echo 'Sending Emails from the Queue.....' . "\n";

$mail_qry = "select id,

charset,

to_name,

to_address,

subject,

text,

from_name,

from_address,

created

from email_batch

where (send is null or send = '') and

(hold is null or hold = '')

order by created asc

limit 5";

$email_query = tep_db_query($mail_qry);

while ($email = mysql_fetch_array($email_query)) {

echo 'Sending...' . $email['id'].' '.$email['to_name'].' '.$email['to_address']."\n";

define('CHARSET', $email['charset']);

$send_result = tep_mail(

$email['to_name'],

$email['to_address'],

$email['subject'],

$email['text'],

$email['from_name'],

$email['from_address']);

echo 'result=[';

if ($send_result) {

tep_db_query("update email_batch set send = 'on', last_updated = now() where id = '" . $email['id']. "'");

echo 'OK]'."\n";

} else {

echo 'ERROR]'."\n";

}

}

echo 'Done'."\n";

mysql_free_result($email_query);

}

?>

 

PS. do you have the configuration cache facility installed? that is, do you use/have includes/configuration_cache_read.php ?

 

 

if not, then you need to install it (recommended contrib) or change this line :

 

require ('includes/configuration_cache_read.php');

 

to this:

 

// set application wide parameters

$configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION);

while ($configuration = tep_db_fetch_array($configuration_query)) {

define($configuration['cfgKey'], $configuration['cfgValue']);

}

Treasurer MFC

Link to comment
Share on other sites

if not, then you need to install it (recommended contrib) or change this line :

 

require ('includes/configuration_cache_read.php');

 

to this:

 

// set application wide parameters

$configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION);

while ($configuration = tep_db_fetch_array($configuration_query)) {

define($configuration['cfgKey'], $configuration['cfgValue']);

}

You were right, I haven't got the configuration_cache_read.php installed. Your code worked just fine inserted into the orginal code.

 

Then I implemented your earlier SQL suggestion. it's "order by" instead of "sort by"

 

$email_query = tep_db_query("select * from email_batch where (send is null or send = '') and (hold is null or hold = '') order by created limit 1 ");

 

Where 1 is the number of emails sent per cron job.

 

Excellent support, many thanks Amanda, I wish you a very happy new year. I use to live in HK not far from Taiwan obviously, do you celebrate Chinese New Year instead?

 

Best regards

 

Robert

Link to comment
Share on other sites

You were right, I haven't got the configuration_cache_read.php installed. Your code worked just fine inserted into the orginal code.

 

Then I implemented your earlier SQL suggestion. it's "order by" instead of "sort by"

 

$email_query = tep_db_query("select * from email_batch where (send is null or send = '') and (hold is null or hold = '') order by created limit 1 ");

 

Where 1 is the number of emails sent per cron job.

 

Excellent support, many thanks Amanda, I wish you a very happy new year. I use to live in HK not far from Taiwan obviously, do you celebrate Chinese New Year instead?

 

Best regards

 

Robert

 

happy new year to you too, we in Taiwan do not choose, we celebrate both.

Treasurer MFC

Link to comment
Share on other sites

  • 2 months later...

Ok, I have this email queue 2.0 installed and have only tested it with contact_us.php as of now. My goal is to have it working with contact_us.php, checkout_process.php, and create_account.php (three files that i know use tep_mail) Tested this with contact_us.php and it puts it into the queue but It doesn't send it out unless i do something with cronjob or click the send button next to it in queue.

 

So this is what I'm wanting this to do. When a customer clicks send or continue on the contact_us page for example I want the email to be sent to me automatically like it does by default PluS send a copy of that to queue to store it here for later viewing and if a customer creates an account I want the create account notification e-mail to be sent to me automatically and copied to queue or stored in queue for later viewing and the ability to re-send the customer their welcome letter incase they've forgotten their information to login to their account.

 

I don't know if I have this configured right to do this on the admin side under e-mail options, or if there is something to do with the code to do what I'm trying to do here.

 

 

E-mail settings tried which does put in queue but not automatically send and copy to queue like I would like it to do. e-mail has to be manually sent or cronjob.

 

E-Mail Transport Method sendmail

E-Mail Linefeeds CRLF

Use MIME HTML When Sending Emails true

Verify E-Mail Addresses Through DNS false

Send E-Mails true

Use Email Queue true

Hold Email Queue false

 

Now I can have these same settings and have

 

Use Email Queue true

Hold Email Queue true and does the same thing.

 

I even tried Hold e-mail queue true and use email queue false but I assume hold wont work if use email queue is turned off (can't drive the car unless the engine is kicked on per say)

 

 

Please help and thank you

Link to comment
Share on other sites

Ok, I have this email queue 2.0 installed and have only tested it with contact_us.php as of now. My goal is to have it working with contact_us.php, checkout_process.php, and create_account.php (three files that i know use tep_mail) Tested this with contact_us.php and it puts it into the queue but It doesn't send it out unless i do something with cronjob or click the send button next to it in queue.

 

So this is what I'm wanting this to do. When a customer clicks send or continue on the contact_us page for example I want the email to be sent to me automatically like it does by default PluS send a copy of that to queue to store it here for later viewing and if a customer creates an account I want the create account notification e-mail to be sent to me automatically and copied to queue or stored in queue for later viewing and the ability to re-send the customer their welcome letter incase they've forgotten their information to login to their account.

 

I don't know if I have this configured right to do this on the admin side under e-mail options, or if there is something to do with the code to do what I'm trying to do here.

E-mail settings tried which does put in queue but not automatically send and copy to queue like I would like it to do. e-mail has to be manually sent or cronjob.

 

E-Mail Transport Method sendmail

E-Mail Linefeeds CRLF

Use MIME HTML When Sending Emails true

Verify E-Mail Addresses Through DNS false

Send E-Mails true

Use Email Queue true

Hold Email Queue false

 

Now I can have these same settings and have

 

Use Email Queue true

Hold Email Queue true and does the same thing.

 

I even tried Hold e-mail queue true and use email queue false but I assume hold wont work if use email queue is turned off (can't drive the car unless the engine is kicked on per say)

Please help and thank you

 

well, use email queue means use it or not:

 

In your code which normally sends the emails you have changed it to (in contact_us for instance):

 

if (use the email queue){

store the email

}else{

send the email

}

 

so if you set that setting to true the email is stored in the queue and not send, if false it is send and not stored.

 

The hold email queue is the setting to stop all sending of emails from the queue.

The scheduled job tests this setting and if true does not send anything.

The emails are still stored in the queue though.

 

If you do not want the email queue to send the emails via the scheduled job but merely use it as an archive with the option of resending and such, then you change the code to do not either but both:

 

if (use the email queue){

store the email

}

send the email

 

so now it will store the email (if the queue is enabled) AND send it immediately.

Make sure you do not schedule the job or set hold queue to true or you will send duplicates.

Treasurer MFC

Link to comment
Share on other sites

well, use email queue means use it or not:

 

In your code which normally sends the emails you have changed it to (in contact_us for instance):

 

if (use the email queue){

store the email

}else{

send the email

}

 

so if you set that setting to true the email is stored in the queue and not send, if false it is send and not stored.

 

The hold email queue is the setting to stop all sending of emails from the queue.

The scheduled job tests this setting and if true does not send anything.

The emails are still stored in the queue though.

 

If you do not want the email queue to send the emails via the scheduled job but merely use it as an archive with the option of resending and such, then you change the code to do not either but both:

 

if (use the email queue){

store the email

}

send the email

 

so now it will store the email (if the queue is enabled) AND send it immediately.

Make sure you do not schedule the job or set hold queue to true or you will send duplicates.

 

YAY!!!!! Awesome! Got it to work the way I was talking about there with changing

 

if (use the email queue){

store the email

}else{

send the email

}

 

 

to

 

if (use the email queue){

store the email

}

send the email

Link to comment
Share on other sites

YAY!!!!! Awesome! Got it to work the way I was talking about there with changing

 

if (use the email queue){

store the email

}else{

send the email

}

to

 

if (use the email queue){

store the email

}

send the email

 

 

THANK YOU Verryy much for all of your help Amanda :D :thumbsup: :lol: (w00t)

Link to comment
Share on other sites

  • 1 month later...

Hoi Amanda,

 

incoming from contact_us.php is working nicely :D

 

But i cannot get an outgoing e-mail (from ../admin/mail.php to a client) into the queue?

 

I have 4 buttons in place of 3: edit, delete, send, and send mail.

 

When i push: send mail i'm getting the following error:

Fatal error: Call to undefined function: tep_store_mail() in D:\xampp\htdocs\oscommerce\catalog\admin\email_queue.php on line 115

 

114/115/116 are:

114 $this_email = mysql_fetch_array($this_email_query);
115 tep_store_mail($this_email['from_name'], $this_email['from_address'], $this_email['subject'], $this_email['text'], $this_email['to_name'], $this_email['to_address'], 'on');
116 break;

 

Any suggestions?

"If you're working on something new, then you are necessarily an amateur."

Link to comment
Share on other sites

Hoi Amanda,

 

incoming from contact_us.php is working nicely :D

 

But i cannot get an outgoing e-mail (from ../admin/mail.php to a client) into the queue?

 

I have 4 buttons in place of 3: edit, delete, send, and send mail.

 

When i push: send mail i'm getting the following error:

Fatal error: Call to undefined function: tep_store_mail() in D:\xampp\htdocs\oscommerce\catalog\admin\email_queue.php on line 115

 

114/115/116 are:

114 $this_email = mysql_fetch_array($this_email_query);
115 tep_store_mail($this_email['from_name'], $this_email['from_address'], $this_email['subject'], $this_email['text'], $this_email['to_name'], $this_email['to_address'], 'on');
116 break;

 

Any suggestions?

 

simply copy the function tep_store_mail() from includes/functions/general.php to admin/includes/functions/general.php

Treasurer MFC

Link to comment
Share on other sites

simply copy the function tep_store_mail() from includes/functions/general.php to admin/includes/functions/general.php
Thanks again Amanda, no more error, now.

 

But still no mail visible if sent from admin to client

 

Settings:

sendmail

LF

false false

true

true

true

 

FYI: no mailserver on this local machine, only xampp.

 

Another idea please?

"If you're working on something new, then you are necessarily an amateur."

Link to comment
Share on other sites

Thanks again Amanda, no more error, now.

 

But still no mail visible if sent from admin to client

 

Settings:

sendmail

LF

false false

true

true

true

 

FYI: no mailserver on this local machine, only xampp.

 

Another idea please?

 

not visible where?

Treasurer MFC

Link to comment
Share on other sites

not visible where?

In the Email Queue Center in Admin: http://127.0.0.1/2006_A_3/catalog/admin/email_queue.php

if I send an Email from: http://127.0.0.1/2006_A_3/catalog/admin/mail.php nothing arrives in the Email Queue box on the right side.

Header: Email Queue Hold Master-Switch Enabled

 

Greetings

John

"If you're working on something new, then you are necessarily an amateur."

Link to comment
Share on other sites

In the Email Queue Center in Admin: http://127.0.0.1/2006_A_3/catalog/admin/email_queue.php

if I send an Email from: http://127.0.0.1/2006_A_3/catalog/admin/mail.php nothing arrives in the Email Queue box on the right side.

Header: Email Queue Hold Master-Switch Enabled

 

Greetings

John

 

what is the code you have in the while loop of mail.php ?

 

while ($mail = tep_db_fetch_array($mail_query)) {

...

Treasurer MFC

Link to comment
Share on other sites

Original mail.php from osC-version 051113:

 

	//Let's build a message object using the email class
$mimemessage = new email(array('X-Mailer: osCommerce'));
// add the message to the object
$mimemessage->add_text($message);
$mimemessage->build_message();
while ($mail = tep_db_fetch_array($mail_query)) {
  $mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', $from, $subject);
}

tep_redirect(tep_href_link(FILENAME_MAIL, 'mail_sent_to=' . urlencode($mail_sent_to)));
 }

 if ( ($action == 'preview') && !isset($HTTP_POST_VARS['customers_email_address']) ) {
$messageStack->add(ERROR_NO_CUSTOMER_SELECTED, 'error');
 }

 if (isset($HTTP_GET_VARS['mail_sent_to'])) {
$messageStack->add(sprintf(NOTICE_EMAIL_SENT_TO, $HTTP_GET_VARS['mail_sent_to']), 'success');
 }
?>

Thanks for helping to find the solution

Edited by berkedam

"If you're working on something new, then you are necessarily an amateur."

Link to comment
Share on other sites

Original mail.php from osC-version 051113:

 

	//Let's build a message object using the email class
$mimemessage = new email(array('X-Mailer: osCommerce'));
// add the message to the object
$mimemessage->add_text($message);
$mimemessage->build_message();
while ($mail = tep_db_fetch_array($mail_query)) {
  $mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', $from, $subject);
}

tep_redirect(tep_href_link(FILENAME_MAIL, 'mail_sent_to=' . urlencode($mail_sent_to)));
 }

 if ( ($action == 'preview') && !isset($HTTP_POST_VARS['customers_email_address']) ) {
$messageStack->add(ERROR_NO_CUSTOMER_SELECTED, 'error');
 }

 if (isset($HTTP_GET_VARS['mail_sent_to'])) {
$messageStack->add(sprintf(NOTICE_EMAIL_SENT_TO, $HTTP_GET_VARS['mail_sent_to']), 'success');
 }
?>

Thanks for helping to find the solution

 

yes, I know what the original looks like, was more interested in your current version which should use the queue.

Treasurer MFC

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...