Phpmailer Send mail SMTP error:could not authenticate error

Source: Internet
Author: User
Tags php file

Today, when you use Phpmailer to send SMTP mail, you are prompted for an SMTP Error:could not authenticate error, where the password account is correct, and the mailbox is set to turn on SMTP.

Google Baidu over again, some say that the server has disabled the port, and some say that the class.phpmailer.php in the

The code is as follows Copy Code

function Issmtp () {
$this->mailer = ' smtp ';
Change to

function Issmtp () {
$this->mailer = ' SMTP ';
}

After testing or not, the heart of a depressed meter. Finally, in a blog to find a solution, first to share out so that more people encounter the same problem can get help!


This error indicates that the virtual host does not support the Fsockopen function that phpmailer the default call, finds the class.smtp.php file, searches for Fsockopen, and finds such a piece of code:

The code is as follows Copy Code

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? secs

Method 1: Replace the Fsockopen function with the Pfsockopen function


First, remove the following two semicolon from the php.ini


; Extension=php_sockets.dll


; Extension=php_openssl.dll

and then reboot.

Because the Pfsockopen parameters are basically consistent with the fsockopen, you just need to replace @fsockopen with @pfsockopen.

Method 2: Use the Stream_socket_client function

General Fsockopen () is prohibited, Pfsockopen may also be banned, so here is another function stream_socket_client ().

The Stream_socket_client parameter differs from the Fsockopen, so the code is modified to:

The code is as follows Copy Code

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

That's it.


If the above solution is still not resolved may be the mailbox automatically filter your machine automatically login mailbox email Oh, I use the following method to solve

QQ has just started to use the account number, prompted the above error. Replace with the newly registered 163 account number to send normally.


after the exchange of a higher level of QQ account number, this can be sent normally, no report any errors.

Because the recipient is QQ mailbox account number, so send an account with QQ mailbox is better, so send too much will not easily be intercepted or sentenced to junk mail.

So the conclusion is that the configuration of the use of a higher level of QQ account (my small level of 2 of the moon can be used normally, of course, the higher the better,)

PS: Also to check the mailbox "Set email address blacklist" and "receiving rules", sometimes the system will automatically add some mailboxes automatically blacklisted

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.