简体   繁体   English

SMTP服务器需要安全连接VB.NET

[英]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.

相关问题 “SMTP 服务器需要安全连接或客户端未通过身份验证” - “The SMTP server requires a secure connection or the client was not authenticated” VB.net重置SMTP连接 - VB.net Reset SMTP Connection System.Net.Mail.SmtpException SMTP服务器需要安全连接,或者客户端未通过身份验证 - System.Net.Mail.SmtpException The SMTP server requires a secure connection or the client was not authenticated VB.NET GMAIL SMTP服务器设置 - VB.NET GMAIL SMTP Server Settings SMTP服务器需要安全连接,或者客户端未通过身份验证(GMAIL) - The SMTP server requires a secure connection or the client was not authenticated (GMAIL) smtp 服务器需要安全连接或客户端未通过身份验证 5.7 0 - the smtp server requires a secure connection or the client was not authenticated 5.7 0 VB.net SMTP客户端连接错误的建议,尝试通过交换服务器发送邮件 - VB.net Suggestions for SMTP client connection error, trying to send message through exchange server ExecuteReader 需要一个打开且可用的连接 VB.NET - ExecuteReader requires an open and available connection VB.NET 如何在vb.net 2008中保护连接字符串? - How to secure connection string in vb.net 2008? 在vb.net中配置服务器与数据库的连接 - Configuring server connection with database in vb.net
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM