Phpmailer the problem of using QQ mailbox to forward Mail

Source: Internet
Author: User
Tags server port ssl connection
Phpmailer use QQ mailbox to forward the mail error, has been reported 2016-09-21 05:27:59 SMTP notice:eof caught while checking if connected 2016-09-21 05:27:59 SMT P error:could not authenticate. 2016-09-21 05:27:59 SMTP Connect () failed. https://github.com/PHPMailer/... Failed to send mail!

The code to send the message is as follows:

function SendMail ($to, $title, $content) {//Introducing Phpmailer's core file using require_once contains warnings to avoid duplicate definitions of Phpmailer classes require_once ("./     Class.phpmailer.php ");    Require_once ("./class.smtp.php");    Instantiate the Phpmailer core class $mail = new Phpmailer ();    Whether to enable debug for SMTP debugging development environment It is recommended to turn on the production environment comments off can be turned off by default Debug debug mode $mail->smtpdebug = 1;    Use SMTP authentication to send mail $mail->issmtp ();    SMTP needs authentication This must be true $mail->smtpauth=true;    The server address of the link QQ domain mailbox $mail->host = ' smtp.qq.com ';    Set the login authentication using SSL encryption $mail->smtpsecure = ' SSL ';    Set the SSL connection to the SMTP server's remote server port number, the previous default is 25, but now the new seems to be unavailable optional 465 or 587 $mail->port = 465;    Set SMTP Helo message header This optional content arbitrary $mail->helo = ' Hello smtp.qq.com Server ';    Setting the sender's host domain is optional by default to localhost content, it is recommended to use your domain name $mail->hostname = ' http://www.dest.cn ';    Set encoding for sent messages optional GB2312 I like Utf-8 said UTF8 in some clients will be garbled $mail->charset = ' UTF-8 '; Set the sender name (nickname) any content that displays the sender's name before the sender's email address of the recipient's message $mail->fromname = ' TEST lyf3312 '; Sender Everyone name//SMTP login account here fill in the string format QQ number can be $mail-&GT    Username = ' 924634623@qq.com '; The password for the SMTP login uses the generated authorization code (just the latest authorization code that you saved) $mail->password = ' Wrgomczwlipobaib ';    Wrgomczwlipobaib//Set the sender's email address here to fill in the "sender's mailbox" mentioned above $mail->from = ' 924634623@qq.com ';     Whether the message body is HTML-encoded note here is a method that is no longer a property of true or False $mail->ishtml (true); To set a recipient's mailbox address this method has two parameters the first parameter is the recipient's mailbox address the second parameter is a different mailbox system that is set to that address. The second argument here has little meaning $mail->addaddress ($to, ' test    QQ e-Mail Online notification ');//Recipient name//Add multiple recipients the method can be called multiple times//$mail->addaddress (' xxx@163.com ', ' LSGO online notification ');    Add the subject of the message $mail->subject = $title;    Adding ishtml to true on top of the message body can be a complete HTML string such as: Use the file_get_contents function to read the local HTML file $mail->body = $content;    Add an attachment to the message the method also has two parameters the first parameter is the directory where the attachment is stored (either relative to the directory, or the absolute directory) The second parameter is the name of the attachment in the message attachment//$mail->addattachment ('./d.jpg ', ' mm.jpg ');    The same method can be called multiple times to upload several attachments//$mail->addattachment ('./jlib-1.1.0.js ', ' jlib.js ');    $status = $mail->send ();    Simple judgment with hint message if ($status) {return true;    }else{return false; }} $flag = SendMail (' lyf3312@163.com ', ' Test lyf3312 online notification ', ' congratulations on your successful joining the Test lyf3312 lab and start your learning journey! if ($flag) {echo] sent the message successfully! ";} else{echo "failed to send mail! ";}

Strangely, when you turn off SSL and switch to port 25, you can send mail, but you will send out the message.

What's the reason AH ah ah ah ah ah oh ah ah??

  • 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.