Before doing a project to do a phpmailer to send mail with the function of "CI framework combined with phpmailer send mail", yesterday step on the line (just start with Sina cloud, too expensive, replaced by Ali), the test, send an email unexpectedly error ....
I wipe, not on-line time good, the second success, just started I thought is the SMTP address problem (I use 163 mailbox), later changed to QQ mailbox, found or no use, no way, had to ask degrees Niang, later looked at the answer on Baidu to understand in addition to Google's SMTP server received the request " SMTP "will accept that other servers are like the 163,QQ I'm using and must receive an uppercase" SMTP "Request ... emmmmm .....
Then I am in class.phpmailer.php , will
1 Public function issmtp () {2 $this->mailer = ' smtp '; 3 }45// change to 6publicfunction issmtp () {7 $this->mailer = ' SMTP '; 8 }
Then you will:
1 Switch($this-Mailer) {2 Case' SendMail ':3 return $this->sendmailsend ($header,$body);4 Case' SMTP ':5 return $this->smtpsend ($header,$body);6 default:7 return $this->mailsend ($header,$body);8 }9 Ten One //Change into A Switch($this-Mailer) { - Case' SendMail ': - return $this->sendmailsend ($header,$body); the Case' SMTP ': - return $this->smtpsend ($header,$body); - default: - return $this->mailsend ($header,$body); +}
I thought that would do it, restart Apache, test again, the results of the first error is resolved, and an error occurred:
Could Not instantiate mail function
?????
Do not know whether you have appeared, my bad luck, had to turn to the degree Niang, finally found the reason: some virtual host, or server, in order to be safe to shield the "fsockopen () function" cause unable to send the message.
Here's the solution:
First, remove the following two semicolons from the php.ini
; Extension=php_sockets.dll
; Extension=php_openssl.dll
I had already removed it with Phpmailer, just a hint.
Then replace the Fsockopen function
Replace the Fsockopen function in the class.smtp.php file with the Pfsockopen function:
1 $this->smtp_conn = @Fsockopen($host,//The host of the server2 $port,//The port to use3 $errno,//Error number if any4 $errstr,//error message if any5 $tval);//give up after? secs6 7 8 //fsockopen instead:9 $this->smtp_conn = @Pfsockopen($host,//The host of the serverTen $port,//The port to use One $errno,//Error number if any A $errstr,//error message if any - $tval);//give up after? secs
So set up, I have been able to successfully send mail, if the same problem, you can refer to the above example to try.
This article is original content, in order to respect the labor of others, reproduced please specify the address of this article:
Http://www.cnblogs.com/luokakale/p/7302373.html
Send mailtips with Phpmailer SMTP error:could not connect to SMTP host workaround