返回首页

大家好,

我向用户发送注册确认电子邮件后,他registers.The电子邮件通过Gmail smtp.But的发送错误后产生的,它是:
SMTP服务器要求安全连接或客户端未通过身份验证。
这是代码:

 Try

            Dim user As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName.ToString())

            Dim userId As Guid = DirectCast(user.ProviderUserKey, Guid)

            Dim smtp As New SmtpClient()

 

            smtp.Host = "smtp.gmail.com"

            smtp.Port = 587

            smtp.EnableSsl = True

            smtp.DeliveryMethod = SmtpDeliveryMethod.Network

            smtp.UseDefaultCredentials = False

            smtp.Credentials = New NetworkCredential("ahmad.bastas@gmail.com", "password")

            ' Set MailMessage fields.

            e.Message.IsBodyHtml = True

            e.Message.Subject = "Allo Magazine : Registration Confirmation Email"

            ' Replace placeholder text in message body with information 

            ' provided by the user.

            e.Message.Body = e.Message.Body.Replace("<%AC%>", userId.ToString())

            smtp.Send(e.Message)

            'after all of this happens we take the querystring when user presses on activation link and then see if he is not approved we approve him



        Catch ex As Exception

            Response.Write(ex.Message)

 

        End Try

这是在创建用户向导:

{C} 那么,什么是错误?

感谢在前进。

回答

评论会员:游客 时间:2012/02/04
。乌代・辛格:尝试改变codeprelang="vb"smtp.UseDefaultCredentials=spanclass="code-keyword"False/span/pre/code{体C3}并检查了这一点:imgsrc=http://www.orcode.com/img/ico/smiley_smile.gif希望它可以帮助{S0}
koolprasad2003
评论会员:游客 时间:2012/02/04
之前设置的网络凭据设置SSL真正的{的C4}