Skip to content

Instantly share code, notes, and snippets.

@jroenf
Created May 9, 2014 09:31
Show Gist options
  • Save jroenf/0259c031c3d51186a874 to your computer and use it in GitHub Desktop.
Save jroenf/0259c031c3d51186a874 to your computer and use it in GitHub Desktop.
Send an email with Zend Framework 1 and dwoo templates
{extends 'jaloezieen/base/htmlmail.html'}
{block "mailcontent"}
<p>Email</p>
<p>Hello, goodbye</p>
{/block}
// Two methods: first one uses zend layout
// Initialize mail layout
$site = Zend_Registry::get('site');
$oldLayoutPath = $this->_helper->layout->getLayoutPath();
$oldLayout = $this->_helper->layout->getLayout();
$layout = $this->_helper->layout->setLayoutPath(APPLICATION_PATH . '/layouts/scripts/' . $site->theme)->setLayout('mail');
// Send complaint information to customer
$order = $shipment->Order;
$customer = $order->Customer;
$personal = $customer->Invoice_Personal;
$mail = new Zoul_Mail();
$mail->addTo($customer->email, $personal->firstname_initials . ($personal->lastname_prefix ? ' ' . $personal->lastname_prefix : '') . ' ' . $personal->lastname);
$mail->setSubject('['.$order->invoice_number.'] Belangrijke aanvullende informatie over uw zending'); // @todo translate
$layout->content = $this->view->render('mail/damage.html');
$body = $layout->render();
$mail->setBody($body);
$mail->send();
// Restore html layout
$this->_helper->layout->setLayoutPath($oldLayoutPath)->setLayout($oldLayout);
// Second one uses the {extend } option in dwoo
$view->setLfiProtection(false);
$view->addScriptPath(APPLICATION_PATH . 'modules/order/views/scripts/');
$mailBody = $view->render('../../../shipment/views/scripts/mail/shipment.html');
$view->setLfiProtection(true);
$mail->setBody($mailBody);
$mail->send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment