【问题标题】:MvcMailer not working on productionMvcMailer 无法用于生产
【发布时间】:2014-01-23 15:23:55
【问题描述】:

我的web.config 邮件部分是这样的:

<smtp from="mail@gmail.com">
    <network enableSsl="true" host="smtp.gmail.com" port="587" userName="mail@gmail.com" password="pwd" />
</smtp>

在本地测试, 但我在生产中遇到错误(我正在使用共享托管环境):

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.

我用谷歌搜索发现可能solution, 所以我将配置更改为:

<smtp from="mail@gmail.com">
        <network enableSsl="true" host="smtp.gmail.com" port="587" userName="mail@gmail.com" password="pwd" defaultCredentials="true"/>
</smtp>

现在我得到了这个错误:

he SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. ko10sm114859924pbd.38 - gsmtp

我该如何解决这个问题?

我还绑定了添加发货方式:

<smtp from="mail@gmail.com" deliveryMethod="Network">
            <network enableSsl="true" host="smtp.gmail.com" port="587" userName="mail@gmail.com" password="pwd" defaultCredentials="true"/>
    </smtp>

但是怎么样。

更新

我刚刚检查了我的 gmail 并找到了来自 google 的电子邮件

最近有人使用您的密码尝试登录您的 Google 帐户 xxxxxxx@gmail.com。此人正在使用应用程序,例如 电子邮件客户端或移动设备。

我们阻止了登录尝试,以防这是劫机者试图 访问您的帐户。请查看登录尝试的详细信息:

星期一,一月 xxx.xxx UTC IP 地址:xxx.xxx.xxx.xxx 位置:未知

因此,这可能是电子邮件发送无法用于生产的原因。 因为它是一个新位置,当您在 gmail 上从一个新位置登录时,您应该回答安全问题。所以它让场景然后为什么电子邮件不起作用。 所以我现在正在寻找如何在gmail 上解锁该位置/IP 地址,如果可能的话。

【问题讨论】:

  • 您是否尝试过发送具有相同设置的手动电子邮件(直接使用SmtpClient 类)?这至少会消除一种可能性。
  • 如果有帮助,这里是我曾经使用的一些代码的要点:gist.github.com/tiesont/8280201

标签: asp.net asp.net-mvc email asp.net-mvc-5 mailer


【解决方案1】:

改变这个:

<smtp from="mail@gmail.com">

到这里:

<smtp from="mail@gmail.com" deliveryMethod="Network">

编辑:我还找到了this question,希望对您有所帮助。


编辑 2:其他解决方案:

【讨论】:

  • 太糟糕了。您对 gmail 使用 2 因素身份验证吗?
  • 它在本地工作。不,我没有 2f auth 和 gmail。
  • 当然,我的错。查看我编辑中的链接,可能是 IIS 设置。
  • 我在生产环境中使用共享主机环境。我在 IIS 和 IIS express 上进行了本地测试。电子邮件发送时服务器上没有任何 ssl 设置。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-21
  • 2019-04-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-02
相关资源
最近更新 更多