YII emails sent by phpmailer! Yii custom class reference, phpmaileryii
Step 1: Download phpmailer and decompress it to obtain the following three files:
Class. phpmailer. php
Class. pop3.php
Class. smtp. php
Change class. phpmailer. php to phpmailer. php and put the three files
/Protected/extensions/PHPMailer/directory
Modify the phpmailer. php file and add the init method.
Public static function init (){
Return new PHPMailer ();
}
Step 2: Modify/protected/config/man. php
'Components' => array (
'Mail' => array (
'Class' => 'ext. PHPMailer. phpmailer ',
'Charset' => 'utf-8', // your enterprise Post Office Domain Name
'Host' => 'smtp .163.com ', // your enterprise Post Office Domain Name
'Smtpau' => true, // enable SMTP Verification
'Username' => 'etsoftware @ 163.com ', // Post Office Username (Please fill in the complete email address)
'Password' => '******.', // post office Password
'Port' => 25,
'From' => 'etsoftware @ 163.com ', // email address of the email sender
'Fromname' => 'etsoft ',
),
)
Step 3: Use phpmailer to send an email for testing
$ Result = $ mAdmin-> findByPk ($ _ GET ['id']);
$ Mail = Yii: App ()-> mail;
$ Mail-> IsSMTP ();
$ Mail-> AddAddress ('1970 @ qq.com ', 'half-worm ');
$ Mail-> Subject = @ "password change notification"; // mail title
$ Mail-> Body = @ "your password has been changed to $ nPasswd"; // email content
If (! $ Mail-> Send ())
{
Echo $ mail-> ErrorInfo;
// Return false;
} Else {
// Return true;
}
Sent successfully!
How does the controller in yii call the model custom method?
Generally, Model: model ()-> method name is used.
Yii rules rule Customization
Yxmhero1989.blog.163.com/...61864/