This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

sending mail and setting email content

Notes and reports about symfony 1.0.x stable

sending mail and setting email content

by terrid » Mon Dec 06, 2010 4:22 pm

Hi

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?
terrid
Member
 
Posts: 39
Joined: Wed Nov 03, 2010 11:03 am

Re: sending mail and setting email content

by Rose » Fri Feb 11, 2011 8:38 am

I appreciate the updates in here! It could help me how could I possibly send email. I have learned how to work on the email setting content.

My Sports Email
Rose
Junior Member
 
Posts: 1
Joined: Fri Feb 11, 2011 8:32 am