You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WordPress无法连接SMTP服务器求助:GMASS与Telnet可正常连接

WordPress站点无法通过指定SMTP服务器发送邮件(外部测试成功但插件连接失败)

我部署在aiauto.cloud的WordPress站点,想要通过server.cybxpert.com:25251的邮件服务器发送邮件。用GMASS SMTP测试工具和Telnet都能成功连接并收到“Server Ready”提示,但WP-Mail-SMTP、POST SMTP Mailer、SMTP Mailer、FluentSMTP等主流SMTP插件全部提示“连接失败”。我已经反复核对用户名和密码,试过开启/关闭TLS,问题依然存在,求解决方案。


SMTP Mailer v1.1.6连接失败日志

2023-07-31 14:06:35 Connection: opening to server.cybxpert.com:25251, timeout=300, options=array()
2023-07-31 14:06:36 Connection failed. Error #2: stream_socket_client(): Unable to connect to server.cybxpert.com:25251 (Connection refused) [/home/aiaugdju/public_html/wp-includes/PHPMailer/SMTP.php line 389]
2023-07-31 14:06:36 SMTP ERROR: Failed to connect to server: Connection refused (111)
SMTP Error: Could not connect to SMTP host. Failed to connect to server

服务器信息

OS: Linux server167.web-hosting.com
2.6.32-954.3.5.lve1.4.90.el6.x86_64 #1 SMP Tue Feb 21 12:26:30 UTC 2023 x86_64
PHP version: 8.1.21
WordPress version: 6.2.2
WordPress multisite: No
openssl: Available
allow_url_fopen: Enabled
stream_socket_client: Available
fsockopen: Available


GMASS SMTP测试工具成功连接日志

Connected to smtp://server.cybxpert.com:25251/?starttls=when-available
<< 220 server.cybxpert.com ESMTP service ready
>> EHLO [172.31.11.248]
<< 250-server.cybxpert.com says hello
<< 250-ENHANCEDSTATUSCODES
<< 250-PIPELINING
<< 250-CHUNKING
<< 250-8BITMIME
<< 250-AUTH CRAM-MD5 PLAIN LOGIN
<< 250-AUTH=CRAM-MD5 PLAIN LOGIN
<< 250-XACK
<< 250-SIZE 0
<< 250-VERP
<< 250-SMTPUTF8
<< 250 DSN
>> AUTH CRAM-MD5
<< 334 PDk2MzFBMUQ4QHNlcnZlci5jeWJ4cGVydC5jb20
>> YWRtaW5AY3lieHBlcnQuY29tIDhiYWFjZTRkZTRlYzAyNTFiMzRjNjU4ZWRmOWZmZTI5
<< 235 2.7.0 authentication succeeded
>> MAIL FROM:<admin@quizmaster.pro> SIZE=571
>> RCPT TO:<dave.chitchatmedia@gmail.com>
<< 250 2.1.0 MAIL ok
<< 250 2.1.5 <dave.chitchatmedia@gmail.com> ok
>> DATA
<< 354 send message
>> From: admin@quizmaster.pro
>> Date: Mon, 31 Jul 2023 12:59:34 퍍
>> Subject: SMTP test from server.cybxpert.com
>> Message-Id: <38KMYH1QLKU4.KX1VW3033MDM2@WIN-AUIR3RRGP88>
>> To: dave.chitchatmedia@gmail.com
>> MIME-Version: 1.0
>> Content-Type: multipart/alternative; boundary="=-qbnKY3QwxFYSrq/lTyiamw=="
>>
>> --=-qbnKY3QwxFYSrq/lTyiamw==
>> Content-Type: text/plain; charset=utf-8
>>
>> Test message
>> --=-qbnKY3QwxFYSrq/lTyiamw==
>> Content-Type: text/html; charset=utf-8
>> Content-Id: <38KMYH1QLKU4.41OSS1AA1OKI1@WIN-AUIR3RRGP88>
>>
>> <b>Test message</b>
>> --=-qbnKY3QwxFYSrq/lTyiamw==--
>> .
<< 250 2.6.0 message received

可能的解决方案

1. 检查WordPress服务器的出站端口限制

插件日志显示Connection refused (111),说明WordPress所在服务器(aiauto.cloud)的防火墙或主机商可能封禁了25251端口的出站连接——外部测试工具的IP和WordPress服务器IP不同,不受同一限制。

  • 联系主机商,确认是否允许出站访问25251端口;
  • 若主机商限制,尝试更换SMTP服务器的标准端口(如587、465),并在邮件服务器端开启对应端口。

2. 强制使用fsockopen替代stream_socket_client

部分环境中stream_socket_client可能存在配置问题,可尝试让PHPMailer使用fsockopen:

  • 在主题的functions.php中添加以下代码(替换占位信息):
add_action( 'phpmailer_init', 'force_fsockopen_for_smtp' );
function force_fsockopen_for_smtp( $phpmailer ) {
    $phpmailer->SMTPOptions = array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true
        )
    );
    $phpmailer->isSMTP();
    $phpmailer->Host = 'server.cybxpert.com';
    $phpmailer->Port = 25251;
    $phpmailer->SMTPAuth = true;
    $phpmailer->Username = '你的SMTP用户名';
    $phpmailer->Password = '你的SMTP密码';
    $phpmailer->SMTPSecure = 'tls'; // 或根据实际情况设为''(不加密)
    $phpmailer->SMTPAutoTLS = false; // 强制关闭自动TLS,避免协商问题
}
  • 调整参数后测试邮件发送。

3. 检查邮件服务器的IP白名单

邮件服务器可能设置了IP白名单,仅允许特定IP连接——外部测试工具的IP在白名单内,但WordPress服务器的IP未被加入:

  • 登录邮件服务器管理后台,检查白名单设置,将aiauto.cloud服务器的公网IP添加进去;
  • 若不知道WordPress服务器IP,可在站点根目录新建ip.php,内容为<?php echo $_SERVER['SERVER_ADDR']; ?>,访问该文件获取IP。

4. 禁用服务器的ModSecurity或相关安全模块

部分主机的ModSecurity规则可能误拦截SMTP连接请求:

  • 联系主机商临时禁用ModSecurity,测试是否能连接;
  • 若禁用后正常,可让主机商调整规则,允许该SMTP连接。

内容的提问来源于stack exchange,提问作者Dave

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 10:44:51