工作,我有我的web.config
郵件節這樣的:MvcMailer不要在生產
<smtp from="[email protected]">
<network enableSsl="true" host="smtp.gmail.com" port="587" userName="[email protected]" 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.
我GOOGLE了我找到可能solution, 所以我改變我的配置爲:
<smtp from="[email protected]">
<network enableSsl="true" host="smtp.gmail.com" port="587" userName="[email protected]" 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="[email protected]" deliveryMethod="Network">
<network enableSsl="true" host="smtp.gmail.com" port="587" userName="[email protected]" password="pwd" defaultCredentials="true"/>
</smtp>
但浩方式。
UPDATE
我只是檢查我的Gmail和谷歌從
Someone recently used your password to try to sign in to your Google Account [email protected] This person was using an application such as an email client or mobile device.
We prevented the sign-in attempt in case this was a hijacker trying to access your account. Please review the details of the sign-in attempt:
Monday, January xxx.xxx UTC IP Address: xxx.xxx.xxx.xxx Location: Unknown
因此,找出電子郵件可能是爲什麼郵件發送不生產工作的原因。 因爲它是一個新的位置,當您從gmail
上的新位置登錄時,應該回答安全問題。所以它使場景,然後爲什麼電子郵件不工作。 所以我現在正在尋找如何解除阻止位於gmail
如果有可能的位置/ IP地址。
您是否嘗試過用手動發送電子郵件(直接使用'SmtpClient'類)相同的設置?那至少會消除一種可能性。 –
如果有幫助,下面是我用過的一些代碼的一個要點:https://gist.github.com/tiesont/8280201 –