【问题标题】:Using MailKit to connect to a mail server from a third-party hosting provider使用 MailKit 连接到来自第三方托管服务提供商的邮件服务器
【发布时间】:2017-09-21 22:47:12
【问题描述】:

如果我通过第三方托管服务提供商(例如 A2 Hosting)托管 asp.net 核心应用程序,是否可以使用它来发送带有 Mail Kit 的邮件?我尝试了很多不同的东西,client.Connect 只是挂起并最终引发异常。 Ex 为空。

这是我的代码:

            using (var client = new SmtpClient())
            {
                // For demo-purposes, accept all SSL certificates (in case the server supports STARTTLS)
                client.ServerCertificateValidationCallback = (s, c, h, e) => true;

                client.Connect("mail.mydomain.com", 25, false);

                // Note: since we don't have an OAuth2 token, disable
                // the XOAUTH2 authentication mechanism.
                client.AuthenticationMechanisms.Remove("XOAUTH2");

                // Note: only needed if the SMTP server requires authentication
                client.Authenticate("contact@mydomain.com", "PASSWORD");

                client.Send(message);
                client.Disconnect(true);
            }

【问题讨论】:

    标签: asp.net email asp.net-core asp.net-core-mvc mailkit


    【解决方案1】:

    事实证明,我的 ISP (Comcast) 阻止了 25 端口。我的托管公司告诉我,他们为此开放了 2525 端口。我将其更改为 2525 并且它有效。如果您遇到类似问题,请联系您的托管公司,看看他们可能打开了哪些其他端口。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-02
      • 2012-10-27
      • 2017-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多