About Phpmailer sending mail failed failed to connect to server

Source: Internet
Author: User
See a good article, as follows

Sending mail using the Phpmailer class SMTP is unsuccessful; First in the code, we open Smtpdebug$mail = new Phpmailer ();//Set up a mail-sending class

$mail->smtpdebug = true; To set the Smtpdebug property to True

If the message is not sent successfully, an error message is prompted

The mistake I reported was Failed to connect to serverfollowing from address Failed turn on Debug prompt: error:failed to connect To server: (0) since it is not connected, then we look at what is connected, after the mother learned that the connection SMTP server is connected by Fsockopen, then we have to see if this function is disabled in php.ini to find 1,allow_ Url_fopen = on to see if the option is on, when off, the function is definitely not available and is changed to ON. if not, what should I do? Because the above configuration, is said fopen is open state, not to say open can use, but also to allow the use of, well, we look at the method of disabling there is no Fsockopen2,disable_functions Disable_functions This behind, there are a lot of methods to be disabled, there are fsockopen, good congratulations to you, find the answer, will it removed, OK, restart Apache, do not work? Also in the php.ini file, Look, is this open? Extension=php_openssl.dll If it is open, then look at the PHP directory of the two extension files are not copied to c/:windows/system32 under libeay32.dll Ssleay32.dll In addition: Do not change the server, only change the situation of the code, you can also try, note = I did not try

Method 1: Replace the Fsockopen function with the Pfsockopen function

Because the parameters of Pfsockopen are basically consistent with the fsockopen,

So you just need to replace @fsockopen with @pfsockopen. If lucky pfsockopen not been disabled, OK through

Method 2: Use the Stream_socket_client function

General Fsockopen () is banned, and 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:

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

That's all you can do.


This article is from the "909 is a goal" blog, please be sure to keep this source

The connection is as follows:

Http://www.68idc.cn/help/jiabenmake/qita/2014042793331.html

The above describes the Phpmailer send mail failed failed to connect to server, including the aspects of the content, I hope to be interested in PHP tutorial friends helpful.

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