Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

AutoEmailer


  • You cannot reply to this topic
197 replies to this topic

#161 Jack_mcs

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

Posted 12 July 2008, 17:22

The failures you are getting are most likely due to your hosts settings or how the cron job is formatted. You should ask your host about the errors.

For the greeting, try placing it before $message = '.

Jack

#162 peehdee

  • Community Member
  • 10 posts
  • Real Name:MP

Posted 07 August 2008, 22:14

View Postculturebee, on Nov 2 2005, 04:59 AM, 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

try this one:

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

fckeditor not FCKeditor ^^

#163 mr_absinthe

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

Posted 21 October 2008, 17:13

Hi Jack,

my auto emailer was working fine until recently, however it cannot connect to the database for some reason now.

I was trying to call auto_emailer/auto_emailer.php from admin with this path ../includes/configure.php and it is working fine, however it fails when executed via cron. I was also trying to use include(DIR_FS_ADMIN . 'includes/configure.php'); but id did not work either. It keeps throwing the error.

Any ideas what might be wrong?
Absinthe Original Liquor Store

#164 Jack_mcs

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

Posted 21 October 2008, 17:20

Most likely, your host changed something that has affected the cron job. It isn't uncommon for cron jobs to have problems after cpanel updates, assuming that is what you are using, although it may happen with others too. You can ask your host to check it, if your host is one that will do such things.

Jack

#165 mr_absinthe

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

Posted 21 October 2008, 17:43

Thank you for your swift reply, I'll ask them.
Absinthe Original Liquor Store

#166 mr_absinthe

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

Posted 22 November 2008, 12:24

View PostJack_mcs, on Oct 21 2008, 06:20 PM, said:

Most likely, your host changed something that has affected the cron job. It isn't uncommon for cron jobs to have problems after cpanel updates, assuming that is what you are using, although it may happen with others too. You can ask your host to check it, if your host is one that will do such things.
Jack
Jack,

we are still unable to make it work, perhaps you can help. To see and test if it is working, I've created a test file that was placed in admin root:
<?php
ini_set('display_errors','1');
/*
  $Id$
  AutoEmailer by Jack_mcs at www.oscommerce-solution.com
  Released under the GNU General Public License
*/
  include('auto_emailer/class.Email.php');
  include('includes/configure.php');

// option 2 $dbh used instead of $ link
  $dbh=mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD) or die('Cannot connect to the database because: ' . mysql_error());
  mysql_select_db(DB_DATABASE);

  //Set some common items
  $Sender = 'test@site.com';
  $Recipiant = 'test@site.com';
  $Cc = '';
  $Bcc = '';
  $currentDate = date('Y-m-d'); //or enter a date in the form of yyyy-mm-dd

  include('auto_emailer/date_functions.php');

// Start modules 
include('auto_emailer/auto_announce_test.php');
// Stop modules
  echo 'The birthday seems to work now - this is test only!'."\r\n";
  mysql_close($link);
?>
The above file is in admin root and works fine when executed via cron job. However when I place the file in admin/auto_emailer/ folder and execute it via cron, it doesn't work, with the following error: Cannot connect to the database because: Unknown MySQL server host 'DB_SERVER' (1)
The file is almost identical, changed paths obviously, it works when executed from the admin site of the store:
<?php
ini_set('display_errors','1');
/*
  $Id$
  AutoEmailer by Jack_mcs at www.oscommerce-solution.com
  Released under the GNU General Public License
*/
  include('class.Email.php');
  include('../includes/configure.php');

// option 2 $dbh used instead of $ link
  $dbh=mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD) or die('Cannot connect to the database because: ' . mysql_error());
  mysql_select_db(DB_DATABASE);

  //Set some common items
  $Sender = 'test@site.com';
  $Recipiant = 'test@site.com';
  $Cc = '';
  $Bcc = '';
  $currentDate = date('Y-m-d'); //or enter a date in the form of yyyy-mm-dd

  include('date_functions.php');

// Start modules 
include('auto_announce_test.php');
// Stop modules
  echo 'The birthday seems to work now - this is test only!'."\r\n";
  mysql_close($link);
?>

Absinthe Original Liquor Store

#167 Jack_mcs

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

Posted 22 November 2008, 12:37

I don't see why it would fail. But you could hard-code those items, DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD and DB_DATABASE, to see if that makes a difference.

Jack

#168 mr_absinthe

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

Posted 22 November 2008, 13:28

Thank you for your swift reply, it all works fine. But it should also work without hard-coding them, don't you think?
Absinthe Original Liquor Store

#169 Jack_mcs

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

Posted 22 November 2008, 15:17

Yes, It should.

Jack

#170 maxemus

  • Community Member
  • 106 posts
  • Real Name:Raphael Muscarelle
  • Gender:Male

Posted 04 December 2008, 17:58

Ok I got this to work now I'm wondering what is in the persons mind when they developed this to send My Customer report to all of my customers. and I'm wondering where is my order report going?

$customer

Not

$customers

#171 maxemus

  • Community Member
  • 106 posts
  • Real Name:Raphael Muscarelle
  • Gender:Male

Posted 04 December 2008, 18:14

Sorry I was a bit flustered I should offer an explanation there.
I was trying to get this contrib working and was pulling my hair out when i notices that the line

$Recipiant = $customers['customers_email_address'];

was suppose to be

$Recipiant = $customer['customers_email_address'];

That got it to work but I found out that all my customers were getting my customer report. I would watch out for that people. I only noticed because I had a test account in Oscommerce. anyone have a fix for that. Also I don't see my orders report coming out anywhere.

#172 mr_absinthe

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

Posted 09 September 2009, 19:49

Hi Jack,

this is probably php5 related: I'm receiving this warning after the cron job is executed:

Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in /home/xxxxxxx/public_html/admin/auto_emailer.php on line 32

Can it be changed to get rid of that warning please?
Absinthe Original Liquor Store

#173 Jack_mcs

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

Posted 09 September 2009, 23:44

View Postmr_absinthe, on Sep 9 2009, 03:49 PM, said:

Hi Jack,

this is probably php5 related: I'm receiving this warning after the cron job is executed:

Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in /home/xxxxxxx/public_html/admin/auto_emailer.php on line 32

Can it be changed to get rid of that warning please?
I don't see anything wrong with it, other than there isn't any checking done in the code so it might be failing and not handling the error correctly. Try changing this line
mysql_select_db(DB_DATABASE);
to
mysql_select_db(DB_DATABASE, $link);
If it still fails try changing this line
mysql_close($link);
to
mysql_close();

Jack

#174 mr_absinthe

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

Posted 10 September 2009, 10:34

Jack,

thank you for your quick reply, this is the solution that is working now:
I changed this:

Quote

$dbh=mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD) or die('Cannot connect to the database because: ' . mysql_error());
mysql_select_db(DB_DATABASE, $link);
To this:

Quote

$link = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD) or die("Unable to connect to database");
mysql_select_db(DB_DATABASE);
And after that the

Quote

mysql_close($link);
is not causing any warning.
Absinthe Original Liquor Store

#175 jfkafka

  • Community Member
  • 161 posts
  • Real Name:john kafka

Posted 15 October 2009, 17:30

Thanks Jack, for your myriad awesome enhancements!
Whilst testing admin/auto_emailer/auto_announce.php, it appeared that the entire list of customers are returned on the initial $customers_query, then the results are searched for upcoming birthdays, (at least it was in my case)
then it occurred to moi that it might be useful for the storeowner to have advance notice of who(m) was having a birthday like the day before, so combining these 2 items, the auto_announce.php was copied and renamed auto_reminder_birthday.php and modified to send the store owner an email the day before and the initial query was changed to only bring back customers whose birthday matched the month-day search string, in the spirit of osCOM(merce)RADERIE, here is what I did-

oh, just in case - this worked for my version of oscommerce (osCommerce Online Merchant v2.2 RC2a)

1. make a copy of admin/auto_emailer/auto_announce.php

2. rename the copy - auto_reminder_birthday.php

3. replace code in NEW auto_reminder_birthday.php
LOOK FOR:
$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());

$adjYr = substr($currentDate, 0, 4);
$adjMth = (int)substr($currentDate, 5, 2);
$adjMth = str_pad($adjMth, 2, "0", STR_PAD_LEFT);

while ($customer = mysql_fetch_array($customers_query, MYSQL_ASSOC))
{
// Start Date Selection
$adjDate = sprintf("%s-%s-%s", $adjYr, substr($customer['customers_dob'], 5, 2),substr($customer['customers_dob'], 8, 2));
// Stop Date Selection
$diff = DifferenceBetween($currentDate, $adjDate);

// Start Date Difference
if ($diff >= 0 && $diff < 77)
// Stop Date Difference
{
// Start Subject
$Subject = 'test' . ' ' . $customer['customers_firstname'] . ' ' . $customer['customers_lastname'];
// Stop Subject
$Recipiant = $customer['customers_email_address'];

REPLACE WITH: (ordinarily I'd suggest commenting it out but since this is a copy, I simply replaced it)
// 10-15-09 mod to send advance notice to store owner of upcoming birthday
$result = mysql_query("SELECT configuration_value FROM configuration WHERE configuration_key = 'STORE_OWNER_EMAIL_ADDRESS'");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
$row = mysql_fetch_row($result);

$store_owner_email_address = $row[0];
echo $row[0]; // the email value

$adjYr = substr($currentDate, 0, 4);
$adjMth = (int)substr($currentDate, 5, 2);
$adjMth = str_pad($adjMth, 2, "0", STR_PAD_LEFT);
$adjDay = (int)substr($currentDate, 8, 2);

// increment day to show birthdays for tomorrow can be changed to give more advance notice eg 7 for a weeks notice
$adjDay = $adjDay +1 ;
// echo 'adjDay = ' . $adjDay . '<br />';
$searchdate = $adjMth . '-' . $adjDay;
// echo 'searchdate = ' . $searchdate . '<br />';
// search customers_dob by month and day using LIKE for any occurences
$searchdate = '%' . $searchdate . '%';

// THIS PART IS NOTES OF CHANGES- can be deleted
// 10-15-09 original before search for specific date rather than retrieve whole table $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, c.customers_sponsor_email from customers c, customers_info ci where c.customers_id = ci.customers_info_id") or die(mysql_error());
// substring didn't work for moi $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, c.customers_sponsor_email from customers c, customers_info ci where c.customers_id = ci.customers_info_id AND substring(c.customers_dob,5,5) LIKE '$searchdate'") or die(mysql_error());
// X THIS PART IS NOTES OF CHANGES- can be deleted

$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, c.customers_sponsor_email from customers c, customers_info ci where c.customers_id = ci.customers_info_id AND c.customers_dob LIKE '$searchdate'") or die(mysql_error());

while ($customer = mysql_fetch_array($customers_query, MYSQL_ASSOC))
{
$cusdob = substr($customer['customers_dob'],5,5);

// to test
echo "customer = " . $customer['customers_lastname'] . ' cusdob = ' . $cusdob;

// Start Date Selection
$adjDate = sprintf("%s-%s-%s", $adjYr, substr($customer['customers_dob'], 5, 2),substr($customer['customers_dob'], 8, 2));
// Stop Date Selection
$diff = DifferenceBetween($currentDate, $adjDate);

// Start Date Difference
if ($diff >= 0 && $diff < 77)
// Stop Date Difference
{
// Start Subject
$cfirst_name = $customer['customers_firstname'];
$clast_name = $customer['customers_lastname'];

$cdob = $customer['customers_dob'];
// echo 'current date = ' . $currentDate;
/*** another date ***/
$tdate = $currentDate;
//$bday = date("m/d");
$currentmonth = date('M',strtotime($currentDate));
$year = date('Y',strtotime($currentDate));
$byear = date('Y',strtotime($cdob));
$month = date('M',strtotime($cdob));
$day = date('d',strtotime($cdob));
// UNTESTED conditional to increment year if current date is in December and birthday is in January
if ($currentmonth == "Dec" && $month == "Jan") {
$year = $year + 1;
}
$birthday = $year . '-' . $month . '-' . $day;
$weekday = date('l', strtotime($birthday)); // note: first arg to date() is lower-case L
$bday = $weekday . ', ' . $month . ' ' . $day;
//echo 'bday = ' . $bday;
/*** show the date ***/
$age = $year - $byear;

$Subject = 'Reminder - ' . $cfirst_name . ' ' . $clast_name . ' will celebrate their ' . $age . 'th Birthday on ' . $bday . '.';

// orig $Subject = 'test' . ' ' . $customer['customers_firstname'] . ' ' . $customer['customers_lastname'];
// Stop Subject
// this is a new field in customers to use another email to be notified with instead of store owners email $Recipiant = $customer['customers_sponsor_email'];
$Recipiant = $store_owner_email_address;
// X 10-15-09 mod to send advance notice to store owner of upcoming birthday

4. in admin/auto_emailer.php
LOOK FOR:
// Start modules
ADD UNDERNEATH
// 10-15-09 mod to send advance notice to store owner of upcoming birthday
include('auto_reminder_birthday.php');
// X 10-15-09 mod to send advance notice to store owner of upcoming birthday

5. Save these files, upload
6. TEST by calling in browser: changing URL to match your website and admin folder name
http(s)://CHANGE_TO YOUR_WEBSITE.COM!/YOUR_ADMIN_FOLDER(hopefully not called admin for security purposes)/auto_emailer/auto_emailer.php

You should get an echo of results and an email sent to the store owner email address.

I also added a field to customers table called customers_sponsor_email which can be used to designate a different email address if such a situation arose...
There are a few echo statement to show results which can then be commented out or deleted
The conditional IF to increment the year for December/January is untested because, well you know, right?

Hope I touched all the bases,
jk

#176 Jack_mcs

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

Posted 15 October 2009, 18:12

Thanks for posting your code. It sounds like it might be useful to others.

#177 mr_absinthe

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

Posted 23 October 2009, 08:38

Jack,

I'm still experiencing the same issue as last year, but it is getting worse.

One of our customers reported the issue and forwarded our message - "the From field in this email I received from you. Almost 2500 repeats of the from address "info@ourstore.com."

I've not been counting those From fields, but there were a lots!

Any idea what might be causing it please? I need to be pointed some direction where to look at.

It cannot be related to php (now on 5, before on 4) nor sql (now on 5).
Absinthe Original Liquor Store

#178 Jack_mcs

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

Posted 23 October 2009, 13:40

View Postmr_absinthe, on 23 October 2009, 08:38, said:

I'm still experiencing the same issue as last year, but it is getting worse.

One of our customers reported the issue and forwarded our message - "the From field in this email I received from you. Almost 2500 repeats of the from address "info@ourstore.com."

I've not been counting those From fields, but there were a lots!

Any idea what might be causing it please? I need to be pointed some direction where to look at.

It cannot be related to php (now on 5, before on 4) nor sql (now on 5).
While I can almost remember everything I did yesterday (sometimes), :) I can't remember what problem you were having a year ago. Are you saying the customer received 2,500 emails? If so, and if that matches the number of your customer accounts, then it would seem the loop isn't working properly in that part of the code. But without knowing which part of the application it is, I can't suggest what to look at.

Edited by Jack_mcs, 23 October 2009, 13:41.


#179 mr_absinthe

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

Posted 24 October 2009, 19:51

I'm sorry, I forgot to mention the post number, it is post #153 and #156. :blush:

The customer received one email only, but the "From" field contained some 2500 our email addresses (or the "From: field was repeated 2500 times) . It looked like this:

From: info@mystore.com
From: info@mystore.com
From: info@mystore.com
From: info@mystore.com
From: info@mystore.com
From: info@mystore.com
From: info@mystore.com
From: info@mystore.com
etc, etc

I've contacted my host and they confirmed that the problem's source is going to lie in the PHP code.
Absinthe Original Liquor Store

#180 Jack_mcs

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

Posted 25 October 2009, 00:38

My reply would be the same as before for the most part. The loop is controlled by the results from the database query. It's a pretty simply loop:

- fetch an entry from the database querry
- if the date falls within range, send the email
- start over

If multiple emails are being sent, it seems like it would have to be multiple entries in the database that match the date range and has that customers email address. It could also be that the date comparison code is failing. Are your dates enterered in UL format by chance? That would break the code since it assumes mm/dd/yyyy not dd/mm/yyyy. Other than that, it would be a difficult problem to isolate unless you can make it fail at will.