First step
I use 163 mailbox to send mail, make an attempt, before trying, need to open 163 mailbox authorization code as shown, please remember your authorization code, will be used in the next step
Second Step
Need to download a class Phpmailer, I have this resource has been uploaded, free Oh pro, connected in this http://download.csdn.net/detail/s371795639/9693417
After the download, after decompression This folder placed in the vendor directory, Vendor directory has a Phpmailer folders, that's right ~
Third Step
We should write code.
HTML code:
<body>
<form action= "{: U (' Home/login/changepwd ')}" method= "Post" enctype= "Multipart/form-data" >
e-mail: <input type= "text" id= "Mail" name= "Mail"/>
title: <input type= "text" id= "title" Name= " Title "/>
content <input type=" text "id=" content "name=" content "/> <input"
button "class=" Submit "Name=" submit "value=" send "style=" margin:0 auto;display:block; />
</form>
</body>
Corresponding controller PHP code:
CHANGEPWD ()//Send mail to modify password
{
if(isset$_post[' submit '))
{
if(SendMail ( $_post[' mail '],$_post[' title '],$_post[' content '])
$this->success (' send success. ');
Else
$this->error (' send failed ');
}
$this->display ();
}
Fourth Step
That's the key.
Create the function.php input code below common
<?php/** * Created by Phpstorm. * User:administrator * DATE:2016/11/25 0025 * Time: 11:49//** * Mail Send function * *functionSendMail ($to, $title, $content) {vendor (' phpmailer.phpmailerautoload '); $mail =NewPhpmailer (); Instantiate $mail->issmtp (); Enable SMTP $mail->host=c (' mail_host '); The name of the SMTP server (here, for example, QQ mailbox) $mail->smtpauth = C (' Mail_smtpauth '); Enable SMTP authentication $mail->username = C (' Mail_username '); Your mailbox name $mail->password = C (' Mail_password '); Mailbox Authorization Code (note: This is not a mailbox login password.) ) $mail->from = C (' Mail_from '); The sender's address (i.e. your email address) $mail->fromname = C (' Mail_fromname ');
Sender name $mail->addaddress ($to, "respected customer"); $mail->wordwrap = 50; Set the length of each line of characters $mail->ishtml (' mail_ishtml '); Whether the HTML format mail $mail->charset=c (' Mail_charset '); Set the message encoding $mail->subject = $title; Mail subject $mail->body = $content; Message content $mail->altbody = "This is a plain text body in the non-profit HTML email client"; Message body does not support alternate display of HTML return($mail->send ()); }
The config.php input configuration under Conf is as follows
<?php
Return Array (
//' Configuration item ' => ' config value '
mail_host ' => ' smtp.163.com '),//SMTP server name
' Mail_smtpauth ' =>TRUE, Enable SMTP authentication
' mail_username ' => ' s371795639@163.com ',//Your mailbox name
' mail_from ' => ' s371795639@163.com ',// Sender's address
' mail_fromname ' => ' dust in the guest ',//Sender name
' Mail_password ' => ' ******* ',//Mailbox Authorization Code
' Mail_charset ' = > ' utf-8 ',//Set message encoding
' mail_ishtml ' =>TRUE,//whether HTML format mail
);
Then there should be no problem, at least mine. If the use of QQ mailbox sent seemingly failed, modify the above configuration is not. And I don't know why.
Thank you ~