i created template folder on view & create file name as user_registation.php
sample email template by channa smcs |
public function actionEmail()
{
// echo ''.(print_r($_POST,1)).'
';
if(isset($_POST))
{
// get data on variable by channa
$variables=array(
'{fname}'=>'channa',
'{lname}'=>'bandara',
'{email}'=>'channasmcs@gmail.com',
'{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 = 'hellochannasmcs@gmail.com';
$Telephone = '0715977097';
$to = 'hellochannasmcs@hotmail.com';
$subject = $subject;
$messageAdmin = "Deal Admin";
self::email($name, $email, $subject, $messageUser);
self::email($name, $email, $subject, $messageAdmin, TRUE);
//
// echo ''.(print_r($messageUser,1)).'
';
// echo ''.(print_r($messageAdmin,1)).'
';
}
// $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);
$getvariableArray=array_keys($variables);
$replacevariableArray=array_values($variables);
return str_replace($getvariableArray,$replacevariableArray,$message);
}

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