> I think you better show us the script. This might help to figure out the
> problem.

Okay, here it is:

-- Start

#!/usr/local/bin/php -q
<?php

// Include library files
include 'config.php';
include 'feedlib.php';

// Init log
$log = new ParserLog;

// Define location of mailer lock file
$lock = "$rootdir/batch/mailer.lock";

// See if the script is running - don't want to run it again!!
if (file_exists($lock)) {
   $log->write('Mailer is locked - terminating');
   exit;
}

// Create a lock file
$log->write('Locking mailer');
@touch($lock);
@chmod($lock, 0666);

// Internal mailer class
include ("$coredir/classes/mailer.class.php");

// Grab a database connections
$db  = opendb();
$db2 = opendb();

// Query unsent email
$db->query("SELECT MailID, MailFrom, MailTo, Subject, Body, Headers FROM
Mail WHERE Sent = 0");
while ($db->next_record()) {

   // Create a new email
   $mail = new Mailer($db->field('MailFrom'), $db->field('MailTo'),
$db->field('Subject'), $db->field('Body'), $db->field('Headers'));

   // Log event
   $log->write('Sending mail # ' . $db->field('MailID'));

   // Try to send
   if ($mail->send()) {

      // Mark as sent
      $db2->query('UPDATE Mail SET Sent = 1 WHERE MailID = ' .
$db->field('MailID'));
      $log->write('Mail # ' . $db->field('MailID') . ' sent ok');

   } else {

      // Something went wrong
      $log->write('Mail # ' . $db->field('MailID') . ' FAILED');
   }
}

// Remove the lock file
$log->write('Unlocking mailer');
@unlink($lock);

?>
-- End --



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to