Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

AutoEmailer


197 replies to this topic

#41 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 05 January 2006, 09:38

Jack,

Slowly it is beginning to work... I'll list all changes later. I have the following problems now:

1/ I have finally received the message with subject Happy Birthday jesus only because there is a real customer named Jesus in database having birthday today. If there was nobody with the birthday, I would not receive test message.

2/ if I select Customers & Announce in settings and call the script from my browser, I receive the birthday message for Jesus (she's having birthday) and I can see that customers.csv is being written in auto_emailer folder. However one hour later the file contains only 20 records and browser is still working / loading - the script is not executed yet. We only have about 3000 customers in shop.

3/ if I select Customers & New Products and set the date in New Products to 1st November 2005, I received about 1800 emails (one for each customer) with the list of products - and because we use four languages in our shop, each product description is repeated 4 times in the message body - which could be considered as spam by many. Is there a way to
a/ receive 1 email only for testing purposes?
b/ use 1 description from 1 language only?
c/ use title and shorter description (cca 150-200)? Something that would look like:

Product title
Description, bla, blah, blah... click here for more - this could be the link to a product

Alex
Absinthe Original Liquor Store

#42 Jack_mcs

  • Community Member
  • 24,072 posts
  • Real Name:Jack
  • Gender:Male

Posted 05 January 2006, 14:20

1 - That's correct. No emails will be sent if no one has a birthday.

2 - I don't know what this might be. It shouldn't take that long. I suppose it may be timing out due to a limit on how long a script can run on yur server. If you can create a test site and only run with a few customers, that might help find the problem.

3 - To only send one email, in the auto_emailer/auto_newproducts.php file, after
	 $tmessage->Send();
add
breakl

Yes. The product link is already planned for the next release.

Jack

#43 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 05 January 2006, 15:54

After inserting
breakl
I received no emails at all.

When I select Orders and Announce in settings, no email for orders is received when I call the script from my browser, I receive Happy Birthday email only. I have inserted
echo 'test emial'."\n";
in auto_orders.php but still, received no message.

New Products - is there any chance of including description in one language only?

Just for verification, when I'm done with testing, do I keep the recepiant's email address in auto_emailer.php empty as follows? Or both empty?
//Set some common items
$Sender = 'admin@mysite.com';
$Recipiant = '';

Thanks for your time.

Alex
Absinthe Original Liquor Store

#44 Jack_mcs

  • Community Member
  • 24,072 posts
  • Real Name:Jack
  • Gender:Male

Posted 05 January 2006, 17:19

Oops, that should be break; not breakl.

For the orders problem, be sure to insert the echo statement somewhere outside of any conditions code. For example, find this line:
  $total = 0;
and place teh echo statement after it. If that doesn't work, create a test file containing the following:
<?php
echo 'test'."\r\n";
?>
Name it whatever you want and create a cron job for it. If you don't receive an eamil, then you have some other problem not related to AutoEmailer and you will need to fix that first.

For the language problem, find this line in auto_newproducts.php
  $new_products_query = mysql_query("select p.products_id, p.products_image, p.products_tax_class_id, pd.products_id, pd.products_name, pd.products_description, p.products_date_added, if(s.status, s.specials_new_products_price, p.products_price) as products_price from products p left join products_description pd on p.products_id = pd.products_id left join specials s on p.products_id = s.products_id where products_status = '1' and p.products_date_added >= ' . $date_added . ' order by p.products_date_added desc");
and change it to
  $new_products_query = mysql_query("select p.products_id, p.products_image, p.products_tax_class_id, pd.products_id, pd.products_name, pd.products_description, p.products_date_added, if(s.status, s.specials_new_products_price, p.products_price) as products_price from products p left join products_description pd on p.products_id = pd.products_id left join specials s on p.products_id = s.products_id where products_status = '1' and p.products_date_added >= ' . $date_added . ' and language_id = ' . 1 . ' order by p.products_date_added desc");
I haven't tested this but it should work. Change the 1 to whatever language you want.

That recepiate is a global one meant for all modules. It is overridden in the modules that send out emails to customers. In modules like auto_orders.php, it is used snce the email is only going to you. So it should be set to your email address (or wherever you want).

Jack

#45 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 06 January 2006, 18:24

OK, I created test.php with the following:
<?php
echo 'test'."\r\n";
?>
When I call it from browser, it displays test on the screen. I created cron job for it and received email from cron with "test" in the message body. Therefore cron job is fine and only this path is working for me (I use plesk):
php -q /home/httpd/vhosts/mysite.com/httpdocs/admin/auto_emailer/auto_emailer.php
However when I insert
echo 'test emial'."\n";
in auto_orders.php after $total = 0; it does nothing nor I receive any email with orders.

When I insert break; after $tmessage->Send(); in auto_emailer/auto_newproducts.php, I receive no email. When I delete it, I receive one for each customer, which is annoying, even if I set the date in New Products to yesterday, I still receive hundreds of emails.

After inserting language_id = ' . 1 . ' in mysql_query produced no products nor descriptions in email. I have tried to change it to pd.language_id = ' . 1 . ' and p.language_id = ' . 1 . ' and pd.language_id = '" . (int)$languages_id . "' but nothing works. All I receive is the following message:

Content-Type: text/html; charset="iso-8859-1"

Content-Transfer-Encoding: 8bit





	   <html>

		<head>

		 <title>New products</title>

		</head>

		<body>

		 <p>Hello Justin,<br><br>

			  

  <!-- start message //-->

We are just letting you know of the great new products that recently arrived. Just look at some of the <strong>great items</strong> we now offer:

  <!-- stop message //-->			

			  

		 <br><br> <br> </p>

		</body>

	   </html>
Note that the above message is not html formated. I receive it exactly as it looks.

I have also received the following message from cron, I think it might be related to auto_orders.php
PHP Parse error:  parse error, unexpected ',' in /home/httpd/vhosts/mysite.com/httpdocs/admin/auto_emailer/auto_orders.php on line 28

I am aware Jack that this is time consuming for you, I'm just trying to help making this good contribution better, if it doesn't work for me, I'm sure it will not work for many others. I'll be therefore more than happy to help debugging it.

Alex
Absinthe Original Liquor Store

#46 Jack_mcs

  • Community Member
  • 24,072 posts
  • Real Name:Jack
  • Gender:Male

Posted 07 January 2006, 01:32

Ahh, you have an error in the script. You need to find out what that is before you can do anything else. What's on line 28 of your auto_orders file? If you have a file that is working with cron, test.php, try changing the cron job back to calling auto_emailer.php and in that script, have only one includes statement and make that includes for the text.php file. Do you still get the test message? If so, then the auto_emailer.php file is fine and it is on one of the other files. If not, then something is failing in that script.

Jack

#47 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 07 January 2006, 14:56

auto_emailer.php with include('test.php'); works fine, message received.

auto_emailer.php with include('auto_orders.php'); produced the following error:
PHP Parse error:  parse error, unexpected ',' in /home/httpd/vhosts/mysite.com/httpdocs/admin/auto_emailer/auto_orders.php on line 28
this is line 28 of auto_orders.php
// Start csv header
$_csv_data='.','.'Order Status'.','.'Customer'.','.'Quantity'.','.'Product'.','.'Price' ."\n";
It doesn't look right to me... that line is being changed when selecting boxes in admin/auto_emailer_orders.php. When I used clean file from install package, I received no more erros, however if I call the script from my browser, it keeps loading, orders.csv is being written in a folder on the server, but it only contains headers of columns... same problem as I have with customers. It should take few seconds to execute that script, but it's taking ages and it's never finished.

Alex
Absinthe Original Liquor Store

#48 Jack_mcs

  • Community Member
  • 24,072 posts
  • Real Name:Jack
  • Gender:Male

Posted 07 January 2006, 18:20

Well, that is progress at least. So the auto_emailer.php file is fine and cron is working correctly. I would elimiate as much as I could from the auto_orders.php file to try to find the problem. For example, remove all references to csv code. If it works after that, then that is where the problem is at. If not, remove some other parts. Here is a cut down version. There is not much left and it won't do anything but send you one email but that might indicate something.
<?php
/*
  $Id$
  AutoEmailer by Jack_mcs at www.oscommerce-solution.com
  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2002 osCommerce

  Released under the GNU General Public License
*/
  $message = '
		 <html>
		  <head>
		   <title>Orders Report</title>
		  </head>
		  <body>
		   <p><table width="100%" border="1">
			   <tr>
<!-- Start Header //-->
<th width="15%">Customer</th><th width="15%">Quantity</th><th width="15%">Product</th><th width="15%">Price</th><th width="15%">Weight</th>
<!-- Stop Header //-->
			   </tr>';


  $Subject = 'Orders Report for ' . $currentDate;  
  $tmessage = new Email($Recipiant, $Sender, $Subject, $CustomHeaders);
  $tmessage->Cc = $Cc;
  $tmessage->Bcc = $Bcc;
// Start Order Status
  $ordersStatus = 'Processing';
// Stop Order Status
  $total = 0;

  $customers_query = mysql_query("select customers_id from customers") or die(mysql_error());

  $message .= '</tr>
		   <tr>
<!-- Start Totals //-->
 <td>Total </td>
<!-- Stop Totals //-->
		   </p>
		  </body>
		 </html>
		 ';


  $tmessage->SetHtmlContent($message);
  $pathToServerFile = $_file;
  $serverFileMimeType = 'application/excel';
  $tmessage->SetFileContent($pathToServerFile, $serverFileMimeType);
  $tmessage->Send();

  fclose( $_fp );
?>

Jack

#49 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 08 January 2006, 10:22

Jack,
I tested it with the above file and it works fine, a message with subject "Orders Report for 2006-01-08" was received. This is the body:
Content-Type: text/html; charset="iso-8859-1"

Content-Transfer-Encoding: 8bit





<html>

<head>

<title>Orders Report</title>

</head>

<body>

<p><table width="100%" border="1">

<tr>

<!-- Start Header //-->

<th width="15%">Customer</th><th width="15%">Quantity</th><th width="15%">Product</th><th width="15%">Price</th><th width="15%">Weight</th>

<!-- Stop Header //-->

</tr></tr>

<tr>

<!-- Start Totals //-->

<td>Total </td>

<!-- Stop Totals //-->

</p>

</body>

</html>

Alex
Absinthe Original Liquor Store

#50 Jack_mcs

  • Community Member
  • 24,072 posts
  • Real Name:Jack
  • Gender:Male

Posted 08 January 2006, 14:34

When you say that is the body, do you mean that is the what the email looks like that you received? If so, that is not correct. The html shouldn't be printed out like that. Of course, I didn't test it so maybe I made a mistake on the file I pointed. You will need to play with it. Cut it down to just a few lines. Maybe this one

Quote

<?php
/*
$Id$
AutoEmailer by Jack_mcs at www.oscommerce-solution.com
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright © 2002 osCommerce

Released under the GNU General Public License
*/
$message = '
<html>
<head>
<title>Orders Report</title>
</head>
<body>
<p><table width="100%" border="1"><tr><td>Hello</td></tr></table>
</body>
</html>
';

$Subject = 'Orders Report for ' . $currentDate;
$tmessage = new Email($Recipiant, $Sender, $Subject, $CustomHeaders);
$tmessage->Cc = $Cc;
$tmessage->Bcc = $Bcc;
$tmessage->SetHtmlContent($message);
$serverFileMimeType = 'application/excel';
$tmessage->SetFileContent($pathToServerFile, $serverFileMimeType);
$tmessage->Send();
?>
Once you get a working html message, start building it back up. It sounds like it will work for you but there is something that still not quite right.

Jack

#51 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 08 January 2006, 16:46

Jack,

yes, with the body I meant that it is what the message looks like, now the above code produces following message (subject: Orders Report for 2006-01-08):
Content-Type: text/html; charset="iso-8859-1"

Content-Transfer-Encoding: 8bit





<html>

<head>

<title>Orders Report</title>

</head>

<body>

<p><table width="100%" border="1"><tr><td>Hello</td></tr></table>

</body>

</html>

BTW the Happy Birthday message looks just fine, I need to test if it's sent on a birthday now.

Alex
Absinthe Original Liquor Store

#52 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 08 January 2006, 17:13

Jack,

OK, I did some more testing and it looks like the html problem might be somewhere else... maybe with my host, because when I sent that message to my web mail address, I see table with Hello. So, before I'll sort that out, I'll use my alternative address to test it further. Your code posted in #48 looks just fine, table with 5 columns and there is Total in column Customer.

My other problem could be with birthday message. I created a customer with birthday today, set up cron job on 7am and when the following is in auto_announce.php, I receive no message even if I try to call the script again from my browser:
$Recipiant = $customers['customers_email_address'];
however when I replace it with
$Recipiant = 'test@customerwithbirthday.com'; //$customers['customers_email_address'];
and call the script, I receive birthday message just fine. Am I doing something wrong here and overlooking obvious?

Alex
Absinthe Original Liquor Store

#53 pinto192

  • Community Member
  • 6 posts
  • Real Name:alan

Posted 08 January 2006, 21:35

View Postculturebee, on Nov 1 2005, 09:59 PM, said:

Having problem setting up autoemailer please help getting this error with FCKeditor installed
Warning: main(../../admin/FCKeditor/fckeditor.php): failed to open stream: No such file or directory in /home/xxxxxxxxxx/public_html/admin/includes/functions/html_output.php on line 12

Warning: main(../../admin/FCKeditor/fckeditor.php): failed to open stream: No such file or directory in /home/xxxxxxxxx/public_html/admin/includes/functions/html_output.php on line 12

Fatal error: main(): Failed opening required '../../admin/FCKeditor/fckeditor.php' (include_path='.:/usr/local/lib/php') in /home/xxxxxxxxxx/public_html/admin/includes/functions/html_output.php on line 12
in my html_output i have this 'home/xxxxxxxxx/public_html/admin/FCKeditor/');

thank you


I found a easier way to fix this problem. I added it to a new install so this problem doesn't happen anymore.

When installing "require("../../FCKeditor/fckeditor.php");" in the html_output.php file some people forget to edit it. Here is the fix!

require(DIR_FS_ADMIN . '/FCKeditor/fckeditor.php');

That will fix your problems

#54 pinto192

  • Community Member
  • 6 posts
  • Real Name:alan

Posted 08 January 2006, 21:47

I am having issues with the auto emailer...

When I go to /admin/auto_emailer_announce.php from my browser It all works but

THe editor doesn't show up, and in the message box I it pulls up http://yoursite.com?

Kinda lost on how to fix. I am gonna go in myself see whats going on here. be great if someone knows the fix

#55 Jack_mcs

  • Community Member
  • 24,072 posts
  • Real Name:Jack
  • Gender:Male

Posted 09 January 2006, 00:21

View Postmr_absinthe, on Jan 8 2006, 12:13 PM, said:

My other problem could be with birthday message. I created a customer with birthday today, set up cron job on 7am and when the following is in auto_announce.php, I receive no message even if I try to call the script again from my browser:
$Recipiant = $customers['customers_email_address'];
however when I replace it with
$Recipiant = 'test@customerwithbirthday.com'; //$customers['customers_email_address'];
and call the script, I receive birthday message just fine. Am I doing something wrong here and overlooking obvious?

Alex
It would seem the email address is not being read in from the database. If you place the following line right after that one, do you receive an email with the customers name?
echo 'Customers name is '.$Recipiant."\r\n";

Jack

Edited by Jack_mcs, 09 January 2006, 00:22.


#56 Jack_mcs

  • Community Member
  • 24,072 posts
  • Real Name:Jack
  • Gender:Male

Posted 09 January 2006, 00:24

View Postpinto192, on Jan 8 2006, 04:47 PM, said:

I am having issues with the auto emailer...

When I go to /admin/auto_emailer_announce.php from my browser It all works but

THe editor doesn't show up, and in the message box I it pulls up http://yoursite.com?

Kinda lost on how to fix. I am gonna go in myself see whats going on here. be great if someone knows the fix
If the editor isn't showing up, it is either not installed or not installed correctly. Go back over the install directions to be sure you have it setup as needed.

Jack

#57 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 09 January 2006, 10:21

OK, the situation is as follows. We know that the cron is working fine, so I'm calling the script from my browser. When I use the following in auto_announce.php
$Recipiant = $customers['customers_email_address'];
I receive no messages at all.

$Recipiant = $customers['customers_email_address'];
		 echo 'Customers name is '.$Recipiant."\r\n";
Produced "Customers name is" message on the screen and no email.

$Recipiant = 'test@customer.com'; //$customers['customers_email_address'];
		 echo 'Customers name is '.$Recipiant."\r\n";
Produced the following message on the screen: "Customer name is test@customer.com" and email was received at test@customer.com. Message "Customer name is" wasn't included in the email.

Any idea what could be done to make it work? Thanks a lot.

Alex
Absinthe Original Liquor Store

#58 Jack_mcs

  • Community Member
  • 24,072 posts
  • Real Name:Jack
  • Gender:Male

Posted 09 January 2006, 13:41

Make sure you still have the $customers_query = mysql_query... and the while ($customer = ... lines in your auto_announce.php file. I know it has been edited so if that code was deleted, it won't work. If the code is there, then take a look at your actual database and ensure that that customer really has an email address.

Jack

#59 mr_absinthe

  • Community Member
  • 368 posts
  • Real Name:Alex
  • Location:London, UK

Posted 09 January 2006, 14:57

I have double checked the file, the query is there. Also the customer, who's having birthday today (me) has a valid email address in database in customers_email_address column. If I use that address in auto_announce.php instead of
$Recipiant = $customers['customers_email_address'];
and call the script, the email is delivered to that address just fine, therefore it is getting correct information about the dob.

Alex
Absinthe Original Liquor Store

#60 Jack_mcs

  • Community Member
  • 24,072 posts
  • Real Name:Jack
  • Gender:Male

Posted 09 January 2006, 15:47

Hey, Happy Birthday. :) Give this a try. It should send you an email with all of your customers names and email addresses. If it does, then post the auto_announce.php file you are using and I will test it here. if it doesn't, or some of them are missing, then it has to do with your database.
<?php
  $customers_query = mysql_query("select c.customers_id, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_email_address, ci.customers_info_date_account_created, ci.customers_info_id from customers c, customers_info ci where c.customers_id = ci.customers_info_id") or die(mysql_error());
  while ($customer = mysql_fetch_array($customers_query, MYSQL_ASSOC))
  {
	 echo 'Customer ' . $customer['customers_firstname'] . ' ' . $customer['customers_lastname'] . ' EMail '. $customers['customers_email_address'] . "\r\n";
  }
?>

Jack