After some trials I decided to switch to a CLI version of this script,
because in some cases I need to send the same email to multiple recipients.
My solutions is similar to yours, this is a proof of concept:

// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, 
                APPLICATION_PATH . '/configs/application.ini');
$application->bootstrap();

$view = new Zend_View();
$view->setScriptPath(APPLICATION_PATH . '/views/scripts/index');

$articles = new Mailing_Model_Articles();

$view->articles = $articles->fetchTodaysNews();

$layoutVars = array ();

$layoutVars['content'] = $view->render('index.phtml');

$layout = new Zend_Layout(
                array (
                                'layoutPath' => APPLICATION_PATH . 
'/layouts/scripts/', 
                                'view' => $view));

$friends = array (
                array ('name' => 'friend1', 'email' => '[email protected]'), 
                array ('name' => 'friend2', 'email' => '[email protected]'));

$mail = new Zend_Mail();
$mail->setSubject('News')->setFrom('[email protected]');

foreach ($friends as $friend) {
        $view->friend = $friend['name'];
        $layout->assign($layoutVars);
        $mail->addTo($friend['email']);
        $mail->setBodyHtml($layout->render());
        $mail->send();
        $mail->clearRecipients();
}

Thanks anyway for your response.


David Mintz-2 wrote:
> 
> On Mon, Aug 31, 2009 at 4:01 PM, David Mintz <[email protected]> wrote:
> 
> [Damn this gmail! your focus accidentally gets on the send button and you
> press the wrong key and presto! your email is sent prematurely, speaking
> of
> email. Hate it when that happens. Anyway, I meant to say...]
> 
> $this->_helper->layout->setLayout('foobaz');
> $mailer = new Zend_Mail();
> $mailer->addTo( $user->email, "$user->firstname $user->lastname" )
>    ->setBodyHtml( $this->view->render( 'your/view.phtml' ) )
>    ->setFrom ( '[email protected]', "Whomever" )
>    ->setSubject ( "Your subject line" )
>    ->send ();
> 
> HTH.
> 
> -- 
> David Mintz
> http://davidmintz.org/
> 
> The subtle source is clear and bright
> The tributary streams flow through the darkness
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-email-the-result-of-a-dispatched-request-%28or-better-how-to-save-generated-html%29-tp25211572p25230917.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to