新安裝了discuz3.5,安裝完成后,基本算工作正常吧,但是今天在發送郵件時,卻無法發出,設置和原來discuz3.4一樣,按照官網里的解釋,是因為新的設置里有一個超時設置需要設置,我設置了超時時間后,還是問題依舊,看/data/log文件里的smtp日志,提示是Unable to connect to the SMTP server,檢查了端口,防火墻,一切都沒有問題,后來從以前的一篇文章里提到,phpmailer在ssl模式下在php7.4以上版本都有問題,解決方式可以參考以前的文章。不過單就discuz的問題,需要更改的設置卻在source/function/function_core.php這個文件里,只要將原來的設置屏蔽掉,按照原來的那篇文章介紹的,更新設置即可。
找到
function fsocketopen($hostname, $port = 80, &$errno = null, &$errstr = null, $timeout = 30) {
$fp = '';
if(function_exists('fsockopen')) {
$fp = @fsockopen($hostname, $port, $errno, $errstr, $timeout);
} elseif(function_exists('pfsockopen')) {
$fp = @pfsockopen($hostname, $port, $errno, $errstr, $timeout);
} elseif(function_exists('stream_socket_client')) {
$fp = @stream_socket_client($hostname.':'.$port, $errno, $errstr, $timeout);
}
return $fp;
}這段屏蔽掉,然后改成
function fsocketopen($hostname, $port = 80, &$errno = null, &$errstr = null, $timeout = 30) {
$fp = '';
if(function_exists('stream_socket_client')) {
$contextOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$context = stream_context_create($contextOptions);
$fp = @stream_socket_client($hostname.':'.$port, $errno, $errstr, $timeout,STREAM_CLIENT_CONNECT, $context);
}
return $fp;
}即可。