Skip to content

SMTP在Windows上无法使用mail函数发邮件,请剔除这个模块 #25459

Closed

Description

@hu-weicheng

Description

The following code:
//SMTP在Windows上无法使用mail函数发邮件,请剔除这个模块

<?php

Resulted in this output:

But I expected this output instead:

PHP Version

PHP 8.6.0RC7 (cli) (built: Nov 11 2026 23:42:49) (ZTS Visual C++ 2026 x64)
Copyright © The PHP Group and Contributors
Built by The PHP Group
Zend Engine v4.6.0RC7, Copyright © Zend by Perforce
    with Zend OPcache v8.6.0RC7, Copyright ©, by Zend by Perforce

Operating System

Win11

Activity

  1. devnexen commented on Nov 14, 2026

    @devnexen
    Member

    So I asked chatgpt to help on this :)

    The issue template was left empty, so there is no reproducer or error message to look at.

    On Windows, mail() uses a minimal built-in SMTP client: it does not support SMTP authentication or TLS (STARTTLS / SMTPS). Most mail providers require both, so mail() can only deliver through a relay that accepts unauthenticated connections (for example a local MTA on localhost:25). This is a known limitation rather than a bug.

    For sending through a provider, please use a library such as PHPMailer or Symfony Mailer, which support authentication and encryption.

    Removing mail() on Windows would be a backward compatibility break and would need to go through the RFC process (https://wiki.php.net/rfc/howto), so it can't be handled as a bug report. Closing for now. If you get a specific warning from mail() against a server that does not require authentication, feel free to reopen with the exact message and your SMTP/smtp_port/sendmail_from settings.

    谢谢反馈。Windows 上的 mail() 使用内置的简易 SMTP 客户端,不支持 SMTP 认证和 TLS 加密,因此无法直接通过需要认证的邮件服务商发送邮件。这是已知限制,不是 bug。建议使用 PHPMailer 或 Symfony Mailer。移除该功能属于不兼容变更,需要走 RFC 流程。

  2. hu-weicheng commented on Nov 15, 2026

    @hu-weicheng
    Author

    我知道了,感谢恢复!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions