G. php send mail function implementation (using 163 mailbox)

Source: Internet
Author: User

The first step

I use 163 mailbox to send mail, do an attempt, before attempting, need to open 163 mailbox Authorization Code, please remember your authorization code, will be used in the following steps

Step Two

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, unzip the folder in the vendor directory, the vendor directory has a Phpmailer folders, that's right ~

Step Three

We should write the code.

HTML code:

<body><form action= "{: U (' Home/login/changepwd ')}" method= "Post" enctype= "Multipart/form-data" >    Email: <input  type= "text" id= "Mail" name= "Mail"/>    title: <input  type= "text" id= "title" Name= "title"/ >    content <input  type= "text" id= "content" name= "content"/>    <input class= "button" type= "Submit" Name= "Submit" value= "send" style= "margin:0 auto;display:block;" /></form></body>

PHP code for the corresponding controller:

public function  changepwd ()//Send mail to modify password {if  (if  (SendMail ($_post[' mail '],$_post[' title '],$_post[' content ')) $this->success (' sent successfully!       ‘);    

Fourth Step

This is the key.

Under common, establish the function.php input code as follows

<?php/*** Created by Phpstorm.* User:administrator* DATE:2016/11/25 0025* Time:Morning11: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 (in this case, QQ mailbox) $mail->smtpauth = C (' Mail_smtpauth '); Enable SMTP authentication $mail->username = C (' Mail_username '); Your mailbox name $mail->password = C (' Mail_password '); email password $mail->from = C (' Mail_from '); The sender's address (that is, your email address) $mail->fromname = C (' Mail_fromname ');    Sender's name $mail->addaddress ($to, "Dear Customer"); $mail->wordwrap = 50; Sets the length of characters per line $mail->ishtml (C (' mail_ishtml ')); Whether HTML-formatted mail $mail->charset=c (' Mail_charset '); Set the message encoding $mail->subject = $title; Message subject $mail->body = $content; Message content $mail->altbody = "This is a plain text body in a non-profit HTML email client"; The message body does not support alternate display of HTMLreturn($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 ,//Whether HTML-formatted mail); 

Then there should be no problem, at least mine. If use QQ mailbox send seemingly always failed, modify the above configuration is not. I don't know why.

Thank you ~
Source: http://www.cnblogs.com/findumars/p/6323729.html

G. php send mail function implementation (using 163 mailbox)

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.