emailUsers.php - cron job

Hello,

I paid for some consulting time to create a plug-in that I could setup via a cron job to email users after 3 and 14 days depending on certain actions. It was either Robin or Tom that did this work I think :)

Ross as sent me the file but when I try and run it via cron I receive an error message - something is apparently wrong on Line 17...

<?php


//
$placeholders = array(
'from' => $GLOBALS['SETTINGS']['adminEmail'],
'to' => $, // THIS IS LINE 17
'buyer_name' => $buyerName,
'buyer_email' => $buyerEmail,
'buyer_phone' => $buyerPhone,
'seller_name' => $sellerName,
'subject' => htmlspecialchars($_REQUEST['subject']),
'listing_id' => $_REQUEST['listing_id'],
'listing_item' => $listingsRecord['product']
);


Can you please help to fix this so I can get the file working correctly?

I'm attaching it to this post.

Thank you,
Greg
Attachments:

emailusers.php 10K

Re: [gversion] emailUsers.php - cron job

By Jason - December 7, 2011

Hi Greg,

The problem on line 17:

'to' => $,

is a PHP syntax error. There's a $ but no variable name. The additional problem is that there will also be no value for 'to' in the email.

Change this to the variable you want to send the email to. For example, if you wanted to send the email to the buyer's email, try this:

'to' => $buyerEmail,

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] emailUsers.php - cron job

Hi Jason,

Thanks for the response. I understand the problem.

How do I know whether I should use the buyer's or the seller's email variable? This script send automated emails to both types of users. Perhaps this section deals with the buyer and there is some other code that is used to email the seller...?

Thanks again for your help.

Regards,
Greg

Re: [Jason] emailUsers.php - cron job

Hi Jason,

I have tried putting in the variable that you suggested:

$buyerEmail

However, now I receive the following error message:


MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''contacted' = 'No' ORDER BY cms_contact_seller.createdByUserNum' at line 17



I'd be extremely grateful if you could take another look at this for me.

Thank you,
Greg

Re: [gversion] emailUsers.php - cron job

By (Deleted User) - December 8, 2011

Hello Greg,

The problem is the query is looking for a value 'No' for the field "...contacted" where it should be checking for '0'.

If you find both occurrences of

AND $contactTable.contacted' = 'No'

(lines 139 and 189 in our copy of the file) and replace them with

AND $contactTable.contacted' = '0'

it will eliminate this error.

With regard to the earlier missing variable question (on line 17), you should put your own email address in place of the '$'. The subsequent calls to the emailUsers function all override the 'to' variable anyway and if there is an error with the sending, it would be better for the errant email to come to you!

Hope this helps,

Tom

Re: [gversion] emailUsers.php - cron job

By (Deleted User) - December 8, 2011

Hi Greg,

First step to test is to make a backup copy of the file as it is now (you'll need it later!).

There are four variables that set the timing for the emails:$today = date("Y-m-d");
$threedaysago = date("Y-m-d", strtotime('-3 days'));
$sevendaysago = date("Y-m-d", strtotime('-1 week'));
$fourteendaysago = date("Y-m-d", strtotime('-2 weeks'));


The strings '-3 days','-1 week' and '-2 weeks' can be set to any value, for example '-1 day', with the result that the function will send emails sooner rather than later.

Furthermore, to be 'safe', you should change all references to an email address (all from and to fields) to be your email address so that only you receive any emails generated.

Once you're satisfied that everything is working, re-instate the backup copy of the file.

Hope that helps,

Tom

Re: [Tom P] emailUsers.php - cron job

Hi Tom,

Thanks for explaining this. I will give it a shot and get back to you if I have any problems.

Regards,
Greg