你是谁不重要,重要的是,你闯进我生活想干啥?

SMTP Error: Could not connect to SMTP host...解决方法

本方法总结自网上的所有方法,然后加上自己的整理。希望大家一定要看完。

首先写一段代码,确定问题:

<?php
$fp = fsockopen("smtp.163.com",25,&$errno,&$errstr,60); 
if(! $fp) 
    echo '$errstr   ($errno) <br> \n '; 
else 
    echo 'ok <br> \n ';
?>
然后保存为test.php

方法一:如果输出为ok,那么就是说这个函数没有被禁用。那么就要检查你的邮箱被封了没,这个可能性比较小。那么就要检查自己的服务器是否支持SSL协议。有的空间服务器不支持SSL,所以会提示这个错误。这时候就不能用SSL加密协议,只能使用普通的协议来连接。

方法二:如果报错:php_network_getaddresses: getaddrinfo failed 
可能服务器DNS设置问题,导致不能解析域名、从而找不到stmp服务器。也可能服务器所在网络环境屏蔽掉stmp服务器。如果不是自己的机器,所以只能指定SMTP服务器的ip,就不能为域名了。需要将smtp.pjkui.com改为111.111.111.(此为示例,请不要实际使用)

如果还是不行,就要找服务商了。

方法三:如果报错:Warning: fsockopen() has been disabled for security reasons。
说明fsockopen函数被禁用,PHPmailer发送Email依赖此函数。
解决方法参考《fsockopen函数被禁用的解决之道》,修改class.smtp.php中的代码$this->smtp_conn = @fsockopen 为$this->smtp_conn = @pfsockopen 即可。

如果pfsockopen也不行,需要使用使用stream_socket_client函数来代替,具体使用方法略




最新评论

  • Hi, We run an email marketing service with an audience of over 50 million people and businesses. We can promote your product or service, as well as your blog posts, articles, events, videos, your brand, and we can also generate leads for you. Is this something that you would be interested in? If you have no interest, click here and we won't bother you again: https://removeme.click/em/unsubscribe.php?d=pjkui.com Kind Regards, Charlotte
  • Hi there, We run a YouTube growth service, which increases your number of subscribers both safely and practically. - We guarantee to gain you 700-1500+ subscribers per month. - People subscribe because they are interested in your channel/videos, increasing likes, comments and interaction. - All actions are made manually by our team. We do not use any 'bots'. The price is just $60 (USD) per month, and we can start immediately. If you have any questions, let me know, and we can discuss further. Kind Regards, Sarah
  • Hi there, We run an Instagram growth service, which increases your number of followers safely and practically. We aim to gain you 300-1000+ real human followers per month, with all actions safe as they are made manually (no bots). The price is just $60 (USD) per month, and we can start immediately. Let me know if you are interested and have any questions. Kind Regards, Libby