The error message "SMTPError: Couldnotauthenticate" sent by phpmailer is returned.

Source: Internet
Author: User
When I sent an email using phpmailer today, SMTPError: Couldnotauthenticate was prompted. this is a problem with smtp Settings. I have found several solutions on the Internet. Using php today... the SMTP Error: cocould not authenticate is prompted when you use phpmailer to send an email today. this is a problem with smtp Settings. below I have found several solutions on the Internet.

When phpmailer is used to send an smtp mail today, it prompts SMTP Error: cocould not authenticate Error. the password account is correct, and the SMTP function is enabled in the mailbox.

Google Baidu once again, some say that the server has disabled the port, and some say that the code in class. phpmailer. php is as follows:

Function IsSMTP () {$ this-> Mailer = 'smtp ';} // change to function IsSMTP () {$ this-> Mailer = 'smtp ';}

After the test, I still couldn't do it. I was so depressed that I found a solution in my blog. I first shared it so that more people who encountered the same problem could get help!

This error indicates that the VM does not support the fsockopen function called by PHPMailer by default. find the class. smtp. php file and search for fsockopen. the following code is found:

// connect to the smtp server  $this->smtp_conn = @fsockopen($host,// the host of the server  $port,// the port to use  $errno,   // error number if any  $errstr,  // error message if any  $tval);   // give up after ? secs

Method 1: replace the fsockopen function with the pfsockopen function,First, remove the two semicolons below in php. ini.

; Extension = php_sockets.dll

; Extension = php_openssl.dll

Restart the system. because the pfsockopen parameter is basically the same as that of fsockopen, replace @ fsockopen with @ pfsockopen.

Method 2: Use the stream_socket_client function

Generally, fsockopen () is disabled, and pfsockopen may also be disabled. So here we will introduce another function stream_socket_client (). the parameters of stream_socket_client are different from those of fsockopen, so the code should be modified as follows:

$ This-> smtp_conn = stream_socket_client ("tcp: //". $ host. ":". $ port, $ errno, $ errstr, $ tval );

In this way, if the above method is still not solved, it may be because the mailbox is automatically filtered and your machine is automatically logged on to the mailbox to send an email. I am using the following method to solve this problem, the above error is prompted for the first qq account. If you change to a newly registered 163 account, the message can be sent normally. After that, I changed to an account with a relatively high qq level, which can be sent normally without any error. Because the recipient uses a qq mailbox account, it is better to use a qq mailbox for the sender account, so sending too many emails will not be easily intercepted or identified as spam. Therefore, the conclusion is that an account with a relatively high qq level is used in the configuration. (I can use two moon accounts with a small number. of course, the higher the level, the better ,)

Conclusion: You must also check "set email address blacklist" and "email receiving rules" in your mailbox. sometimes, the system automatically adds some mailboxes to the blacklist.

Related Article

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.