以下测试机器环境以及是否邮件发送存在问题,我先是测试(输出如截图左侧,可以正常链接socket,并且获取到正确的链接):
- <?php
- // The server details that worked for you in the above step
- $smtp_host = 'ssl://smtp.exmail.qq.com';
- //The port that worked for you in the above step
- $smtp_port = 465;
- $socket = fsockopen($smtp_host, $smtp_port, $errno, $errstr, 30);
- echo "$socket 123\n";
- if (!($socket = fsockopen($smtp_host, $smtp_port, $errno, $errstr, 30)))
- {
- echo "Error connecting to '$smtp_host' ($errno) ($errstr)";
- }
- $lastmessage = fgets($socket, 512);
- if(substr($lastmessage, 0, 3) == '220') {
- echo $lastmessage;
- echo substr($lastmessage, 0, 3);
- fclose($socket);
- }
- ?>
复制代码 但是相同的代码,在source/function/function_main.php 中,却始终链接不上socket,不是超时,而是直接返回空,并且错误码为0
- } elseif($_G['setting']['mail']['mailsend'] == 2) {
- // The server details that worked for you in the above step
- $smtp_host = 'ssl://smtp.exmail.qq.com';
- //The port that worked for you in the above step
- $smtp_port = 465;
- // $smtp_host = $_G['setting']['mail']['server'];
- // $smtp_port = $_G['setting']['mail']['port'];
- if(!($fp = fsockopen($smtp_host, $smtp_port, $errno, $errstr, 30))) {
- runlog('SMTP', "($smtp_host $smtp_port $errno $errstr) CONNECT - Unable to connect to the SMTP server, ", 0);
- return false;
- }
- stream_set_blocking($fp, true);
- $lastmessage = fgets($fp, 512);
- if(substr($lastmessage, 0, 3) != '220') {
- runlog('SMTP', "{$_G[setting][mail][server]}:{$_G[setting][mail][port]} CONNECT - $lastmessage", 0);
- return false;
- }
- fputs($fp, ($_G['setting']['mail']['auth'] ? 'EHLO' : 'HELO')." uchome\r\n");
- $lastmessage = fgets($fp, 512);
- if(substr($lastmessage, 0, 3) != 220 && substr($lastmessage, 0, 3) != 250) {
- runlog('SMTP', "({$_G[setting][mail][server]}:{$_G[setting][mail][port]}) HELO/EHLO - $lastmessage", 0);
- return false;
- }
复制代码
|