PHP头条
热点:

发送邮件SMTP Error Could not connect to SMTP host. send fail的解决办法


(1)服务器不能使用smtp的形式发送邮件

解决办法:很多网站列出的解决办法说是因为smtp大小写的问题,虽然问题的本质不在这里,但确实也需要改这个地方,至于为什么,看下面的操作。

在 class.phpmailer.php 中,将:

function IsSMTP(){$this->Mailer='smtp';}

改成:

function IsSMTP(){$this->Mailer = 'SMTP';}

这个地方的修改不是使用了smtp来发送邮件,而是使用了另外一种方式发送邮件,检查 class.phpmailer.php 文件里面有下面这么一段:

switch($this->Mailer){
	case 'sendmail':
		return $this->SendmailSend($header, $body);
	case 'smtp'://由于SMTP和smtp不相等 所以选择的是下面MailSend发送邮件 并不是使用smtp发送邮件
		return $this->SmtpSend($header, $body);
	default:
		return $this->MailSend($header, $body);
}

(2)Linux主机禁用了fsockopen()函数

国内有很多空间服务商出于安全考虑会禁用服务器的fsockopen函数。

解决方法:

用pfsockopen() 函数代替 fsockopen() ,如果 pfsockopen 函数也被禁用的话,还可换其他可以操作Socket函数来代替, 如stream_socket_client()

在 class.smtp.php 中将 @fsockopen 改成 @pfsockopen

$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

改成:

$this->smtp_conn = @pfsockopen($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

(3)防火墙安全设置规则,如果以上两种方案都不凑效,那估计是防火墙的规则问题了,可以让服务器管理员去掉所有的防火墙规则,然后测试一下,看是否是这个原因。

您可能感兴趣的文章

  • Fatal error Call to undefined function date_default_timezone_set()
  • Fatal error Class 'SoapClient' not found in ...错误处理办法
  • Fatal error Class 'ZipArchive' not found ...... 的解决办法
  • php提示PHP Warning: date(): It is not safe to rely on the......错误的解决办法
  • php提示Maximum execution time of 30 seconds exceeded...错误的解决办法
  • 网页缓存控制 Cache-control 常见的取值有private、no-cache、max-age、must-revalidate 介绍
  • 该如何解决php运行出现Call to undefined function curl_init错误
  • php Output Control 深入理解 ob_flush 和 flush 的区别

www.phpzy.comtrue/php/760.htmlTechArticle发送邮件SMTP Error Could not connect to SMTP host. send fail的解决办法 (1)服务器不能使用smtp的形式发送邮件 解决办法:很多网站列出的解决办法说是因为smtp大小写的问题,虽然问题的本质不...

相关文章

相关频道:

PHP之友评论

今天推荐