As we all knows email functionalities in websites is common and used in all web application. Either it is registration process or detail of any order, we always need to send an email to our valuable users and clients.
For sending the email using Email Template follow the below steps :-
Step 1 - First collect all the details which we want to send in an Email like first name, last name address etc.
$emailTemplateData = array('fname'=>'Web Technology','lname'=>'Experts Notes');
Step 2 - Create a Folder having name emails, where we can put the designed email templates file.
Location for email template : application/views/scripts/emails
Step 3 - Now create a template with name registration.phtml for registration email and add following details there.
First name: echo $data['fname'];
Last name: echo $data['fname'];
Folder Location: application/views/scripts/emails
Please Don't forget to add the php scripts for all the php variable used there.
Now Add following code there from where we want to send an email.
$subject ='This is subject';
$view = new Zend_View();
$view->addScriptPath(APPLICATION_PATH . '/views/scripts/emails');
$view->data = $emailTemplateData; //$emailTemplateData must have the values which you are using in registration.phtml
$emailHtml = $view->render('registration.phtml');
$mail = new Zend_Mail();
$mail->setBodyHtml($emailHtml);
$mail->setSubject($subject);
$mail->setFrom("support@example.com", "From domain.com");
$mail->send();
0 Comment(s)