PHP uses phpmailer to send emails?

Source: Internet
Author: User
& Amp; lt ;? Php defines a mail sending function functionsendMail ($ address, $ title, $ message) {code...} if (! $ Mail-& amp; gt; Send () {code ...}} else {code ...}}} sendMail (& quot; 18501773419@163.com & quot;, & quot; Test & quot;, & quot; hi, my name is peace & quot ;);? & Amp; g...

// Define a mail sending Function
Function sendMail ($ address, $ title, $ message ){

// Import the mail file require (". /PHPMailer/class. phpmailer. php "); // create a mail object $ mail = new PHPMailer (); $ mail-> IsSMTP (); $ mail-> Host =" smtp.163.com "; $ mail-> SMTPAuth = true; $ mail-> Username = "18501773419@163.com"; $ mail-> Password = "x "; $ mail-> From = "18501773419@163.com"; $ mail-> FromName = "share weshare"; $ mail-> AddAddress ($ address); $ mail-> IsHTML (true ); $ mail-> Subject = $ title; $ mail-> Body = $ message;

If (! $ Mail-> Send ()){

 return true;

} Else {

 return false;

}

}
SendMail ("18501773419@163.com", "test", "Hello, I'm peace ");
?>
PHP uses phpmailer to send an email, prompting that The verification fails (SMTP Error: cocould not authenticate.). After The verification code is commented out, The following From address failed :?

Reply content:

// Define a mail sending Function
Function sendMail ($ address, $ title, $ message ){

// Import the mail file require (". /PHPMailer/class. phpmailer. php "); // create a mail object $ mail = new PHPMailer (); $ mail-> IsSMTP (); $ mail-> Host =" smtp.163.com "; $ mail-> SMTPAuth = true; $ mail-> Username = "18501773419@163.com"; $ mail-> Password = "x "; $ mail-> From = "18501773419@163.com"; $ mail-> FromName = "share weshare"; $ mail-> AddAddress ($ address); $ mail-> IsHTML (true ); $ mail-> Subject = $ title; $ mail-> Body = $ message;

If (! $ Mail-> Send ()){

 return true;

} Else {

 return false;

}

}
SendMail ("18501773419@163.com", "test", "Hello, I'm peace ");
?>
PHP uses phpmailer to send an email, prompting that The verification fails (SMTP Error: cocould not authenticate.). After The verification code is commented out, The following From address failed :?

You need to enable the SMTP service in the mailbox. You can set it in the mailbox ~ 163 the SMTP password should be assigned separately to the mailbox

(PS: use QQ mail to send messages. Note that the port number is not the default 25 !!!)

Class. smtp. php does not have require.
Check the environment log and improve the debug level of phpmailer.

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.