How can I make email template in Zend Framework?

前端 未结 2 1329
误落风尘
误落风尘 2021-01-29 18:47

I want to make email templates in Zend Framework.

For example,



Dear {$username$},
This is a invitation email sent by
2条回答
  •  长发绾君心
    2021-01-29 19:18

    Hi this is realy common.

    Create an view script like : /views/emails/template.phtml

    
    name; ?>
    

    Welcome

    mysite; ?>

    and when creating the email :

    // create view object
    $html = new Zend_View();
    $html->setScriptPath(APPLICATION_PATH . '/modules/default/views/emails/');
    
    // assign valeues
    $html->assign('name', 'John Doe');
    $html->assign('site', 'limespace.de');
    
    // create mail object
    $mail = new Zend_Mail('utf-8');
    
    // render view
    $bodyText = $html->render('template.phtml');
    
    // configure base stuff
    $mail->addTo('john@doe.com');
    $mail->setSubject('Welcome to Limespace.de');
    $mail->setFrom('support@limespace.de','Limespace');
    $mail->setBodyHtml($bodyText);
    $mail->send();
    

提交回复
热议问题