SMTP 在我的域和 gmail 上失败

SMTP fails on my domain and on gmail

编辑:我要补充一点,该域由 Web.com 托管。也许其他人使用它们并且经历过类似的事情。

下面的代码是为我自己的 smtp 服务器和 gmail 设置的。两者都因不同的原因而失败。我在 VS 2010/.Net 4

中写这个

当我从我自己的域 smtp 服务器发送时,我没有收到任何异常,我只是从不发送任何电子邮件。我试过从不同的账户发送到不同的账户。没有例外,就是永远不会交付。我更改了密码并确实收到了身份验证错误,这似乎证明我的凭据是正确的。我正在按照我的域名和端口的域名托管服务商说明进行操作。

使用 gmail 我收到错误,"The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at"。我阅读了此内容并点击链接以允许安全性较低的设备访问我的 gmail。我收到了来自 gmail 的确认电子邮件,表明我已经对安全性较低的电子邮件进行了更改,但我仍然收到相同的错误。

我已阅读并尝试了以下链接中的所有内容,但无法通过。

http://ithoughthecamewithyou.com/post/sending-email-via-gmail-in-cnet-using-smtpclient

c# SmtpClient class not able to send email using gmail

http://blogs.msdn.com/b/mariya/archive/2006/06/15/633007.aspx

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

在查看我正在使用的代码时,有没有什么不对劲的地方突然出现?是 属性 设置错误还是我遗漏了 属性?

Public Shared Sub SendMailMessage(ByVal sfrom As String, ByVal recepient As String, ByVal bcc As String, ByVal cc As String, ByVal subject As String, ByVal body As String)
    Try
        Dim mMailMessage As New MailMessage()

        mMailMessage.From = New MailAddress(sfrom)
        mMailMessage.To.Add(New MailAddress(recepient))

        If Not bcc Is Nothing And bcc <> String.Empty Then
            mMailMessage.Bcc.Add(New MailAddress(bcc))
        End If

        If Not cc Is Nothing And cc <> String.Empty Then
            mMailMessage.CC.Add(New MailAddress(cc))
        End If

        mMailMessage.Subject = subject
        mMailMessage.Body = body

        mMailMessage.IsBodyHtml = True
        mMailMessage.Priority = MailPriority.Normal

    'GMAIL
        'Dim mSmtpClient As New SmtpClient()
        'mSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network
        'mSmtpClient.UseDefaultCredentials = True
        'mSmtpClient.EnableSsl = True
        'mSmtpClient.Host = "smtp.gmail.com"
        'mSmtpClient.Port = 587
        'mSmtpClient.Credentials = New System.Net.NetworkCredential("my gmail address", "my password")
        'mSmtpClient.Send(mMailMessage)

    'MY DOMAIN
        Dim mSmtpClient As New SmtpClient()
        mSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network
        mSmtpClient.UseDefaultCredentials = True
        mSmtpClient.EnableSsl = False
        mSmtpClient.Host = "smtp.mydomain.com"
        mSmtpClient.Port = 587
        mSmtpClient.Credentials = New System.Net.NetworkCredential("my full email address", "my password")
        mSmtpClient.Send(mMailMessage)
    Catch ex As Exception
        'HttpContext.Current.Response.Redirect("~\EmailError.aspx")
        MsgBox(ex.Message, MsgBoxStyle.Information)
    End Try
End Sub

对于 gmail,我的密码太弱了。啊!为什么 Google 不能直接告诉我,而不是说 "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at"

这是一个身份验证错误,所以消息是准确的,只是误导。我生命中的 6 个小时,我再也回不来了。哦,加上我在 phone 和 Web.com 支持上花费的无用的半小时。