站长 - 邮件设置
选择 通过 SOCKET 连接 SMTP 服务器发送(支持 ESMTP 验证)
添加新SMTP服务器
ssl://mail.semen.cc 465 √ noreply@semen.cc noreply@semen.cc 你的密码
保存后,点击 测试,然后填入:
noreply@semen.cc
noreply@semen.cc
即:自己给自己发送一个邮件测试。。。
发现发送失败,,,,
检查日志:
/data/log/202302_SMTP.php
发现无法连接,检查代码后发现,是这个问题:https://www.cnblogs.com/coolid/p/13099053.html
复现错误:
<?php
if(!function_exists('fsockopen')) {
echo '系统不支持fsockopen函数,请联系空间商';
}
$fp = fsockopen('ssl://mail.semen.cc', 465, $errno, $errstr, 60);
if(!$fp) {
echo "联接失败了".$errstr;
} else {
echo "联接成功哦";
}
异常:
Warning: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /www/wwwroot/okboy/testmail.php on line 6
Warning: fsockopen(): Failed to enable crypto in /www/wwwroot/okboy/testmail.php on line 6
Warning: fsockopen(): unable to connect to ssl://mail.semen.cc:465 (Unknown error) in /www/wwwroot/okboy/testmail.php on line 6
联接失败了
解决方案:修改 source/function/function_core.php,注释原来的fsocketopen函数,新增以下fsocketopen方法:
function fsocketopen($hostname, $port = 80, &$errno, &$errstr, $timeout = 15) {
$fp = '';
if(function_exists('stream_socket_client')) {
$contextOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false
)
);
$context = stream_context_create($contextOptions);
$fp = @stream_socket_client($hostname.':'.$port, $errno, $errstr, $timeout,STREAM_CLIENT_CONNECT, $context);
}
return $fp;
}
测试后可以正常放邮件,就是以后dz升级要注意下这块或者重新编译系统环境。
|