从docker连接到office365 SMTP时出现异常

从docker连接到office365 SMTP时出现异常,docker,smtp,office365,Docker,Smtp,Office365,我正在使用MailBee SMTP v11.2发送电子邮件。尝试从Docker上托管的API连接到office365 smtp服务时遇到问题。我在Centos 7服务器上运行docker。同样的代码在IIS、Windows server上托管的API中工作。 我的配置: 服务器:smtp.office365.com 安全:StartTLS,端口587 异常:发生SocketException。InnerException消息如下:由对等方重置连接 我尝试用StartTLS端口587连接到Yaho

我正在使用MailBee SMTP v11.2发送电子邮件。尝试从Docker上托管的API连接到office365 smtp服务时遇到问题。我在Centos 7服务器上运行docker。同样的代码在IIS、Windows server上托管的API中工作。 我的配置: 服务器:smtp.office365.com 安全:StartTLS,端口587 异常:发生SocketException。InnerException消息如下:由对等方重置连接

我尝试用StartTLS端口587连接到Yahoo SMTP。它起作用了,所以防火墙不是问题。 我还尝试使用错误的密码连接到office365,但它返回了身份验证错误的异常,因此我认为它仍然成功连接到office365,但之后出现了错误。 几天后我就被它绊倒了

有人有解决办法吗?

对不起,我没有这方面的信息, 我的演示代码

        var smtpServer = new SmtpServer()
        {
            Name = "smtp.office365.com",
            AccountName = "my account",
            Password = "my password",
            Port = 587
        };
        smtpServer.SslMode = MailBee.Security.SslStartupMode.UseStartTls;
        smtpServer.SslProtocol = MailBee.Security.SecurityProtocol.Auto;
        smtpServer.AuthMethods = MailBee.AuthenticationMethods.Auto;

        var smtp = new Smtp("key");
        smtp.SmtpServers.Add(smtpServer);
        smtp.Message.Builder.HtmlToPlainMode = MailBee.Mime.HtmlToPlainAutoConvert.IfHtml;
        smtp.Message.XMailer = "Testing tool";
        smtp.Message.Charset = "utf8";

        smtp.Connect();
        smtp.Hello();
        smtp.Login();
Mailbee日志文件:

[01:54:37.88] [INFO] Assembly version: 11.2.0 build 590 for .NET Core 2.0. 
[01:54:37.88] [INFO] Will resolve host "smtp.office365.com".
[01:54:37.94] [INFO] Host "smtp.office365.com" resolved to IP address(es) 40.100.54.226, 40.100.54.18, 52.98.85.194, 52.98.77.98, 2603:1046:c02:1820::2, 2603:1046:201:16::2, 2603:1046:202::2, 2603:1046:202:1::2.
[01:54:37.94] [INFO] Will connect to host "smtp.office365.com" on port 587.
[01:54:37.98] [INFO] Socket connected to IP address 40.100.54.226 on port 587.
[01:54:38.01] [RECV] 220 HK2PR02CA0150.outlook.office365.com Microsoft ESMTP MAIL Service ready at Sat, 7 Mar 2020 01:53:58 +0000\r\n
[01:54:38.02] [INFO] Connected to mail service at host "smtp.office365.com" on port 587 and ready.
[01:54:38.02] [INFO] Will send Hello command (HELO or EHLO).
[01:54:38.02] [SEND] EHLO [172.17.0.28]\r\n
[01:54:38.05] [RECV] 250-HK2PR02CA0150.outlook.office365.com Hello [103.53.91.136]\r\n250-SIZE 157286400\r\n250-PIPELINING\r\n250-DSN\r\n250-ENHANCEDSTATUSCODES\r\n250-STARTTLS\r\n250-8BITMIME\r\n250-BINARYMIME\r\n250-CHUNKING\r\n250 SMTPUTF8\r\n
[01:54:38.06] [INFO] SMTP Hello completed.
[01:54:38.06] [INFO] Notify server that we are ready to start TLS/SSL negotiation.
[01:54:38.06] [SEND] STARTTLS\r\n
[01:54:38.09] [RECV] 220 2.0.0 SMTP server ready\r\n
[01:54:38.11] [INFO] Will start TLS/SSL negotiation sequence.
[01:54:38.36] [INFO] TLS/SSL negotiation completed.
[01:54:38.36] [INFO] Will send Hello command (HELO or EHLO).
[01:54:38.36] [SEND] EHLO [172.17.0.28]\r\n
[01:54:38.39] [RECV] 250-HK2PR02CA0150.outlook.office365.com Hello [103.53.91.136]\r\n250-SIZE 157286400\r\n250-PIPELINING\r\n250-DSN\r\n250-ENHANCEDSTATUSCODES\r\n250-AUTH LOGIN XOAUTH2\r\n250-8BITMIME\r\n250-BINARYMIME\r\n250-CHUNKING\r\n250 SMTPUTF8\r\n
[01:54:38.39] [INFO] SMTP Hello completed.
[01:54:38.40] [INFO] Will login as "my Office365 account".
[01:54:38.40] [INFO] Will try SASL LOGIN authentication method.
[01:54:38.41] [SEND] AUTH LOGIN ********\r\n
[01:54:38.44] [RECV] 334 UGFzc3dvcmQ6\r\n
[01:54:38.44] [SEND] ********\r\n
[01:54:40.66] [RECV] 235 2.7.0 Authentication successful\r\n
[01:54:40.66] [INFO] Logged in as "my Office365 account".
[01:54:40.67] [SEND] QUIT\r\n
[01:54:40.77] [RECV] 221 2.0.0 Service closing transmission channel\r\n
[01:54:40.91] [INFO] Error: SocketException occurred. InnerException message follows: Connection reset by peer
[01:54:40.91] [INFO] Will disconnect from host "smtp.office365.com".
[01:54:40.91] [INFO] Disconnected from host "smtp.office365.com".

没有代码,没有日志文件内容。请同时提供。您可以更新到MailBee的最新版本,看看是否有帮助。