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

PHPMailer SMTP连接失败求助(EasyPHP环境)

Troubleshooting "SMTP ERROR: Failed to connect to server" in EasyPHP with PHPMailer

Let’s work through the most likely fixes for this issue, since you’ve already checked openssl and switched to TLS/587:

  • Confirm openssl is actually active
    Editing php.ini doesn’t always take effect right away. First, restart your EasyPHP web server. Then create a quick test file with <?php phpinfo(); ?>, run it in your browser, and search for "openssl" — make sure the "OpenSSL support" line says "enabled". Also, double-check you edited the correct php.ini file (EasyPHP sometimes has separate configs for web and CLI; use the path shown in phpinfo to confirm).

  • Validate SMTP server credentials and core settings
    Even with TLS/587 set, small misconfigs here break connections:

    • Is your SMTP host correct? (e.g., smtp.gmail.com for Gmail, smtp.office365.com for Outlook)
    • Did you enable SMTP authentication? Add $mail->SMTPAuth = true; to your PHPMailer setup if you haven’t.
    • Are your username/password accurate? For services like Gmail, if 2FA is enabled, you’ll need an app-specific password instead of your regular account password. Avoid using "allow less secure apps" long-term, but it can help test if auth is the issue.
  • Test network access to the SMTP server
    Your machine might be blocked from reaching port 587. Open your terminal and run:

    telnet your-smtp-host.com 587
    

    If you get a timeout or "connection refused", check your Windows Firewall or third-party antivirus — they might be blocking outgoing traffic on that port. Temporarily disable the firewall to test, then add an exception for EasyPHP if that fixes it.

  • Bypass SSL certificate verification (for testing only)
    Local environments often don’t trust the SMTP server’s SSL certificate. Add this to your PHPMailer code to rule out certificate issues:

    $mail->SMTPOptions = array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true
        )
    );
    

    Important: Don’t leave this enabled in production — it’s only for debugging.

  • Update PHPMailer to the latest version
    Older PHPMailer releases can have bugs with TLS connections. Grab the latest stable version and replace your current PHPMailer files in the project.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 10:04:20