newsletter Creating & sending dynamic email template for different events like REGISTRATION, FORGOT PASSWORD, etc.

  1. Purpose
  2. Benefits
  3. Requirements
  4. Installation
  5. Usage


  • As we all use email templates into website; here's the best solution which we all can try and can have easy outcomes.
  • It would provide a feel of using CMS.
  • This module is used for creating a dynamic email template for different events like REGISTRATION, FORGOT PASSWORD, LOGIN, etc.
  • If there are any changes into template's content then website Admin have to goto the developer to change the content. By using this website Admin can manage the content by themselves.
  • Newsletter template also have a Active-Inactive facility for enable or disable template.


  • Non technical users can also use it.
  • Reduces production time.


  • Yii 1.1


1) Download file and unzip it into protected/modules.

2) In config/main.php

		'newsletter' =>array(
			'components' => array(
				'tools' => array(

3) Go to the protected directory of your project and run this command in terminal:-

$ php yiic migrate --migrationPath=application.modules.newsletter.migrations
$ yiic migrate --migrationPath=application.modules.newsletter.migrations


1) Add this code for menu in views/layouts/main.php :- In items array,

      array('url'=>array('/newsletter/eventNewsletterTemplate/index'), 'label'=>'EventNewsletter'),
      array('url'=>array('/newsletter/newsletterTemplate/index'), 'label'=>'Newsletter'),
      array('url'=>array('/newsletter/eventTemplate/index'), 'label'=>'Event'),

2) Write the below code where you want to send an email :- In Controller,

  // arrParams array contains eventtype same as the event_template table event type
  // repacement array used for variables which you want to replace dynamically from your content

	 $arrParams = array( 'eventtype' => 'FORGOT_PASSWORD',
		                  'replacement' => array(
					             '##USEREMAIL##' => '',
		                         '##USERNAME##' => 'testUser',
	 $emaildetails = Yii::app()->getModule('newsletter')->tools->getdetails($arrParams); //call global function getdetails() of the components/ToolsComponent.php
	 if(!empty($emaildetails)) {
		  $subject = $emaildetails['subject'];
		  $message = $emaildetails['view'];
		  $user = '';				   
	 else {
	     //put your default code of the email parameters

Hey guys, please feel free to revert back with any feedback or queries. Suggestions are always welcomed!!!

0 0
1 follower
Yii Version: 1.1
License: MIT
Category: Mail
Developed by: Saurabh Dhariwal
Created on: Jan 11, 2016
Last updated: 5 years ago


show all

Related Extensions