YII Mail send phpmailer send mail! Yii Custom Class Reference

Source: Internet
Author: User
Tags yii

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

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.