I have a script that connects to the db via propel and then needs to send an email to an email address.
The content needs t be from a static function, i.e. the script gets rows from a table and then this needs to be sent in the setBody() to send.
Is there an easy way of doing this as I can't seem to do a foreach loop in the setBody()
- Code: Select all
<?php
require_once("batch_include.php");
$now = time();
$now_12hours = time() - 86400;
$start = date("Y-m-d H:i:s", $now);
$end = date("Y-m-d H:i:s", $now_12hours);
$comments = CommentPeer::getCommentsByPeriod($start, $end);
$mail = new sfMail();
$mail->initialize();
$mail->setMailer('sendmail');
$mail->setCharset('utf-8');
// definition of the required parameters
$mail->setSender(sfConfig::get('app_email_address'), 'My Company webmaster');
$mail->setFrom(sfConfig::get('app_email_address'), 'My Company');
echo sfConfig::get('app_email_address');
$mail->addAddress(sfConfig::get('app_email_address'));
$mail->setSubject('Your password request');
$mail->setBody('');
// send the email
$mail->send();
//}
- Code: Select all
public static function getCommentsByPeriod($start, $end)
{
$c = new Criteria();
$date1Criterion = $c->getNewCriterion(CommentPeer::CREATED_AT, $start, Criteria::LESS_EQUAL);
$date1Criterion->addAnd($c->getNewCriterion(CommentPeer::CREATED_AT, $end, Criteria::GREATER_EQUAL));
$c->add($date1Criterion);
return CommentPeer::doSelect($c);
}
Any ideas?
