[英]The SMTP server requires a secure connection VB.NET
Dim smtp As New SmtpClient
Dim mail As New MailMessage
smtp.Credentials = New Net.NetworkCredential("mail@gmail", "password")
mail.From = New MailAddress("mail@gmail.com")
mail.To.Add(totxt.Text$)
mail.Body = bodytxt.Text
If Not ListBox1.Items.Count <= 0 Then
Dim d As Integer
Dim attach As New Attachment(ListBox1.Items(d))
mail.Attachments.Add(attach)
End If
mail.Subject = subjecttxt.Text
smtp.EnableSsl = True
smtp.Port = "587"
smtp.Host = "smtp.gmail.com"
smtp.Send(mail)
smtp.Dispose()
done.Text = "Mail sent"
PictureBox4.BackgroundImage = My.Resources.tickfnl
dtls.Visible = False
I am trying to send email from my gmail account.But i am getting the error "The SMTP Server requires a secure connection".I even enabled LESS-SECURE APP login in my account settings.The password and email address is correct.I tried another email but same issue.Any fix ? 我试图从我的gmail帐户发送电子邮件。但是我收到错误消息“ SMTP服务器需要安全连接”。我什至在我的帐户设置中启用了LESS-SECURE APP登录。密码和电子邮件地址正确。另一封电子邮件,但存在相同问题。是否解决?
I TRIED ALL THE SOLUTIONS FROM THE DUPLICATE LINK,STILL THE SAME PROBLEM 我尝试了双重链接中的所有解决方案,但仍然存在相同的问题
**IF I REMOVE THIS LINE **如果我删除此行
smtl.enablessl=true
then i get this error 然后我得到这个错误
the server resposnse was 5.7.0 ** 服务器资源为5.7.0 **
Fixed the error using EASendMail 使用EASendMail修复了错误
Fixed it using EASendmail : 使用EASendmail对其进行了修复:
Panel6.Visible = True
done.Text = "Sending..."
''''''''''''''''''''''''
Dim oMail As New SmtpMail("TryIt")
Dim oSmtp As New EASendMail.SmtpClient()
oMail.From = fromtxt.Text
oMail.To = New AddressCollection(totxt.Text)
oMail.Subject = subjecttxt.Text
If html.CheckAlign = True Then
oMail.HtmlBody = bodytxt.Text
Else
oMail.TextBody = bodytxt.Text
End If
Dim oServer As New SmtpServer(MailConfig.host.Text)
oServer.Port = MailConfig.port.Text
oServer.ConnectType = SmtpConnectType.ConnectSSLAuto
oServer.User = fromtxt.Text
oServer.Password = MailConfig.password.Text
Dim r As Integer
If ListBox1.Items.Count <= 0 Then
Else
oMail.AddAttachment(ListBox1.Items(r))
End If
oSmtp.LogFileName = Application.StartupPath & "\maillog.log"
Try
oSmtp.SendMail(oServer, oMail)
done.Text = "Mail sent !"
PictureBox4.BackgroundImage = My.Resources.tickfnl
Catch ex As Exception
aa = MsgBox(ex.Message)
done.Text = "Sending failed."
PictureBox4.BackgroundImage = My.Resources.excll
End Try
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.