Thursday, December 4, 2014

YII Send Email & get Template content from database Part -2


i created template folder on view & create file name as user_registation.php

sample email template by channa smcs

add add this site controll In code comment u can get basic undestand about what i did

public function actionEmail()
//            echo '
'; if(isset($_POST)) { // get data on variable by channa $variables=array( '{fname}'=>'channa', '{lname}'=>'bandara', '{email}'=>'', '{dob}'=>'1989-01-01', '{password}'=>'thisiamy password', ); // get template using template name by channa $templatedata= self::getemailtemple('User Registration Template') ;// function in controller(configuration) // get template data in to variable by channa $description=$templatedata->description; $subject=$templatedata->subject; // send $description $description to VariableReplaceArray by channa $emailbody= $this->VariableReplaceArray($description, $variables) ; //function in controller(configuration) // send email detail to templte using renderPartial by channa $emailbodydetail=array( 'emailbodydetail'=>$emailbody, ); // send message detail to template by channa $messageUser = $this->renderPartial('/template/user_register',$emailbodydetail,true); // set up email configuration by channa $name = 'channa'; $email = ''; $Telephone = '0715977097'; $to = ''; $subject = $subject; $messageAdmin = "Deal Admin"; self::email($name, $email, $subject, $messageUser); self::email($name, $email, $subject, $messageAdmin, TRUE); // // echo '
'; // echo '
'; } // $this->renderPartial('/template/view'); $this->render('email'); } }
i added  this on controoler file in configuration folder

//        get email template from database by channa
         public static function getemailtemple($temppalatename) {
             return $templatedetail=  Emailtemplate::model()->find("name='".$temppalatename."'");
  // repalce variable syntex related with initialz input by channa
                public function VariableReplaceArray($message,$variables) 
//                    print_r($variable);
                     return str_replace($getvariableArray,$replacevariableArray,$message);

1 comment:

  1. with the mail database in that they got warning and error messages. USA Email Lists