I'm stuck ... emailing new record

3 posts by 2 authors in: Forums > CMS Builder
Last Post: March 31, 2014   (RSS)

By terryally - March 14, 2014

Hi guy,

I need some help. I have tried all manner of stuff without success.

I am running a CMSB (2.14) for a shows database. I want that whenever a new show is entered that it emails me with (some of) the information.

So I decided to use a cron to run every morning. In the PHP file I using the mail function


and in the 

$message = ;

field I am trying to run the output but it's not working.

How do I store the output into a variable to stick into the message field?

Hope it's not too complicated.



By gregThomas - March 18, 2014

Hi Terry,

So you're getting the system to e-mail you a list of all of the new records, but you're unsure how to store a list of the new records in one large string to e-mail? I think something like this should work:

  //Create the empty message variable
  $message = "";

  //Get the date from yesterday in mysql format
  $yesterdayDate = date('Y-m-d 00:00:00', strtotime('-1 day'));

  //Get all of the records created since yesterday
  $newRecords = mysql_select('cars', "`createdDate` > '".$yesterdayDate."'");

  //Cycle through the new records
  foreach($newRecords as $record){
    //Add each cars name to the message string
    $message .= "{$record['title']}\r\n";

Hopefully the notes I've added to the code will explain what is happening at each step. So by using $message .= I'm adding each new record title to the variable on each loop through.



Greg Thomas

PHP Programmer - interactivetools.com

By terryally - March 31, 2014

Hi Greg,

Thanks for your response and apology for the late reply.

This code works well.

Thanks again.