(1)服务器不能使用smtp的形式发送邮件
解决办法:很多网站列出的解决办法说是因为smtp大小写的问题,虽然问题的本质不在这里,但确实也需要改这个地方,至于为什么,看下面的操作。
在 class.phpmailer.php 中,将:
function IsSMTP(){$this->Mailer='smtp';}改成:
function IsSMTP(){$this->Mailer = 'SMTP';}这个地方的修改不是使用了smtp来发送邮件,而是使用了另外一种方式发送邮件,检查 class.phpmailer.php 文件里面有下面这么一段:
立即学习“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)防火墙安全设置规则,如果以上两种方案都不凑效,那估计是防火墙的规则问题了,可以让服务器管理员去掉所有的防火墙规则,然后测试一下,看是否是这个原因。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号