First step: Download Phpmailer unzip to get the following three files
class.phpmailer.php
class.pop3.php
class.smtp.php
Rename class.phpmailer.php to phpmailer.php and put three files in
Under the/protected/extensions/phpmailer/directory
Modify the phpmailer.php file to add the Init method
public static function init () {
return new Phpmailer ();
}
Step Two: Modify/protected/config/man.php
' Components ' =>array (
' Mail ' =>array (
' Class ' = ' ext. Phpmailer.phpmailer ',
' CharSet ' = ' utf-8 ',//your corporate Post office domain
' Host ' = ' smtp.163.com ',//your enterprise postoffice domain
' Smtpauth ' = = true,//enable SMTP authentication
' Username ' = ' [email protected] ',//Post Office User name (please fill in the full email address)
' Password ' = ' ****** ',//Post office password
' Port ' =>25,
' From ' = ' [email protected] ',//email Sender email Address
' FromName ' = ' etsoftware ',
),
)
Step three: Send a message test using Phpmailer
$result = $mAdmin->findbypk ($_get[' id ");
$mail = Yii::app ()->mail;
$mail->issmtp ();
$mail ->addaddress (' [Email protected] ',' Half worm ');
$mail->subject = @ "Password change notification"; Message header
$mail->body = @ "Your password has been modified to $npasswd"; Message content
if (! $mail->send ())
{
Echo $mail->errorinfo;
return false;
}else{
return true;
}
Sent successfully!
YII Mail send phpmailer send mail! Yii Custom Class Reference