Estoy haciendo un sistema de plantillas para los mails. Mi sistema es algo así:
Código PHP:
class Model_Mail {
private $themplate;
private $user;
private $fromMail = "[email protected]";
private $fromName = "mail";
private $subject;
private $bodyHTML;
private $bodyTEXT;
public function Model_Mail($user){
$this->user = $user;
$this->themplate = new Zend_View();
$this->themplate->setScriptPath(APPLICATION_PATH . '/emails/');
$this->themplate->setHelperPath(APPLICATION_PATH . '/helpers/');
}
public function sendMail() {
$mail = new Zend_Mail('UTF-8');
$mail->setFrom($this->fromMail, $this->fromName);
$mail->addTo($this->user->email, $this->user->name . ' ' . $this->user->lastname);
$mail->setSubject($this->subject);
$mail->setBodyHtml($this->bodyHTML);
$mail->setBodyText($this->bodyTEXT);
$mail->send();
}
public function welcome() {
$this->subject = '¡Bienvenid@!';
// variables
$this->themplate->user = $this->user;
$this->bodyHTML = $this->themplate->render('welcomeHTML.phtml');
$this->bodyTEXT = $this->themplate->render('welcomeTEXT.phtml');
return $this;
}
Código PHP:
$mail = new Model_Mail($user);
$mail->welcome()->sendMail();
Supongo que hay algo que me olvido a la hora de hacer el Zend_View.... pero no veo qué es....
A alguien se le ocurre?
¡¡Gracias!!