Thursday, December 4, 2014

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

Standard


in priviouse blog  make send user email & admin email .
in this blog i coding sent email using email template  & get email content from data base .

1.create email template table to insert email data




CREATE TABLE IF NOT EXISTS `emailtemplate` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(55) NOT NULL,
  `variables` varchar(255) NOT NULL,
  `subject` varchar(255) NOT NULL,
  `description` text NOT NULL,
  `status` enum('1','0') NOT NULL DEFAULT '1' COMMENT '0=inactive,1=active',
  PRIMARY KEY (`id`),
  KEY `id` (`id`)
);

then  i created back end data manage option in my web site back end ..pretty cool



insert data like this 



INSERT INTO `emailtemplate` (`id`, `name`, `variables`, `subject`, `description`, `status`) VALUES
(1, 'User Registration Template', '{fname},{lname},{email},{dob}{password}', 'User Registration', '\r\n Thank You Regiter With Us ....

\r\n\r\n After you register, your request will be sent to the site administrator for approval. You will then receive an email with further instructions.

\r\n
\r\n Your name : {fname} {lname}
\r\n
\r\n Email : {email}
\r\n
\r\n DOB: {dob}
\r\n
\r\n Password: {password}
\r\n
\r\n Thank you
\r\n
\r\n Stream line staff
\r\n', '1');
now back end look like this


i initialize variable for uni q detail variable is static & we can use it globally

                   please see        Part -2



0 comments:

Post a Comment