Yii framework implements email activation [Digital Signature], yii framework
The example in this article describes how to activate a mailbox in the Yii framework. We will share this with you for your reference. The details are as follows:
Controller:
// Send an email and activate the account public function actionEmail () {$ email = Yii ::$ app-> request-> get ('email '); // digital signature $ em_1 = md5 ($ email); // send $ mail = Yii: $ app-> mailer-> compose (); $ mail-> setTo ($ email); $ mail-> setSubject ("Activate email "); // publish a text with html tags $ mail-> setHtmlBody ("<a href = 'HTTP: // www.small2.com/backend/web/index.php? R = login/live & em_1 = ". $ em_1. "& email = ". $ email. "'> click this link </a>"); if ($ mail-> send () echo "success"; else echo "false"; die (); // email sending OK} // activate account public function actionLive () {$ email = Yii: $ app-> request-> get ('email '); $ em_1 = Yii: $ app-> request-> get ('em _ 1'); // echo $ em_1; die; $ em_2 = md5 ($ email ); // echo $ em_2; die; if ($ em_1 = $ em_2) {$ res = Yii: $ app-> db; $ data = $ res-> createCommand () -> update ("login", ["status" => 1], ["ema Il "=> $ email])-> execute (); if ($ data) {echo" <script> alert ('activated successfully, logged on '); location. href = 'index. php? R = login/login' </script> ";} else {echo" <script> alert ('activation failed'); location. href = 'index. php? R = login/login' </script> ";}} else {echo" <script> alert ('parameter error, reactivate '); location. href = 'index. php? R = login/login' </script> ";}}
Principle: (after registration, the original status is changed to 0 by default, and 1 after activation .)