大家好,
我向用户发送注册确认电子邮件后,他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} 那么,什么是错误?
感谢在前进。