【问题标题】:cannot connect to an smtp server over telnet error 504无法通过 telnet 连接到 smtp 服务器错误 504
【发布时间】:2017-10-09 10:38:13
【问题描述】:

我在尝试通过 telnet 登录我的电子邮件服务器时收到 504 错误。我试过 25 和 587 端口。(用 *s 和 xs 屏蔽域和 ips)。

>EHLO domain.com 
250-************.outlook.office365.com Hello [xx.xx.xx.xx]
250-SIZE 157286400
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250 CHUNKING
> HELP
214-This server supports the following commands:
214 HELO EHLO STARTTLS RCPT DATA RSET MAIL QUIT HELP AUTH BDAT
> AUTH
504 5.7.4 Unrecognized authentication type 
[*************.********.****.outlook.com]
> auth
504 5.7.4 Unrecognized authentication type 
[*************.********.****.outlook.com]
> AUTH LOGIN
504 5.7.4 Unrecognized authentication type 
[*************.********.****.outlook.com]
> auth login
504 5.7.4 Unrecognized authentication type 
[*************.********.****.outlook.com]

虽然我可以使用 phpmailer 做到这一点!:

        <?php
        $mail = new PHPMailer(true);
        $mail->IsSMTP();
        $mail->Host = $host;
        $mail->Port = 587;
        $mail->SMTPDebug = 2;
        $mail->SMTPSecure = "tls";
        $mail->SMTPAuth = true;
        $mail->Username = $user;
        $mail->Password = $password;
        $mail->SetFrom($user, "chiliNUT");
        $mail->Subject = $subject;
        $mail->MsgHTML($content);
        $mail->send();

在身份验证的背后,它正在做的事情:

public function Authenticate($username, $password) {
    // Start authentication
    fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
    //...

我怎样才能在命令行上运行它?

【问题讨论】:

    标签: php smtp phpmailer telnet smtp-auth


    【解决方案1】:

    这是因为大多数明智的邮件服务器不允许未加密的 AUTH - 请注意,您从服务器收到的功能列表不包括 AUTH - 您需要首先调用 STARTTLS,PHPMailer 会自动执行此操作。您无法使用 telnet 轻松手动执行此操作 - 使用 openssl 的 s_client 命令做得更好。 PHPMailer 故障排除指南中有一个示例,例如:

    openssl s_client -starttls smtp -connect smtp.outlook.office365.com:587
    

    【讨论】:

      猜你喜欢
      • 2016-07-20
      • 2017-08-16
      • 1970-01-01
      • 2014-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-09
      相关资源
      最近更新 更多