YII emails sent by phpmailer! Yii custom class reference, phpmaileryii

Source: Internet
Author: User

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.