It's work before, but suddenly there was this problem last month. Without changing the code
In my issue is when i trying to send the email with SmtpClient In VB.net .It's throw exception error message as
System.Net.Mail.SmtpException: The SMTP server requires a secure
connection or the client was not authenticated. The server response
was: 5.7.0 Authentication Required.
Whether I use app password / less secure app access also with same error!
Code of below :
Using client As New SmtpClient(AccountOption.AccMailSMTP, AccountOption.AccMailPort) 'SMTP: smtp.gmail.com & Port: 587
message = New MailMessage(ParamEmail, fileReaderEmail) 'From Email & To Email
Dim rich As New RichEditControl
Dim test As New MemoryStream(AccountOption.AccMailDefaultContent)
rich.LoadDocument(test, DocumentFormat.Html)
message.Attachments.Add(New Attachment(file))
message.Subject = subject.Name & " For " & IO.Path.GetFileName(debtorFolder)
message.IsBodyHtml = True
message.Body = rich.HtmlText
client.UseDefaultCredentials = True
client.Credentials = New Net.NetworkCredential(ParamEmail, ParamPassword) 'To Email & The Password / App Password
client.DeliveryMethod = SmtpDeliveryMethod.Network
client.Timeout = 10000
client.EnableSsl = True
Try
client.Send(message)
Catch ex As Exception
Throw ex
End Try
End Using
The Link i have tried . But it same:
How do I send an email with Gmail and SmtpClient when the sending account uses two factor authentication?
The server response was: 5.7.0 Authentication Required. Learn more at
hi go to your google account in the security panel
Click on turn off/on access (recommend)
in the opened panel it must be turned on
Related
When I used this code to send mail on the visual studio 2012 server (localhost), the mail has been sent successfully. But it shows an authentication problem when I'm free web hosting from smarterasp.net.What problem is going on?
Private Sub sendCode()
'email verify
Dim Random As Random = New Random()
activationCode = Random.Next(1001, 9999).ToString()
Session("activationCode") = activationCode
'email sending
Dim smtp As SmtpClient = New SmtpClient()
smtp.Host = "smtp.gmail.com"
smtp.Port = 587
smtp.EnableSsl = True
smtp.UseDefaultCredentials = False
smtp.Credentials = New NetworkCredential("xyz#xyz.com", "xxxxxxx")
Dim msg As MailMessage = New MailMessage("xyz#xyz.com", Session("toEmail"), "Activation Code to verify Email Address", "Dear, Alumni your Activation Code is " + activationCode + "\n\n\nThanks & Regards\nVidyasagar University CS Students")
Try
smtp.Send(msg)
lblMessage.Text = "Mail sent successfully"
Session("isFromCheck") = "yes"
Response.Redirect("emailVerification.aspx")
Catch ex As Exception
lblMessage.Text = ex.Message
End Try
End Sub
I expect the mail sending should be successful as on my development server
but it shows me ------->
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
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Mail.SmtpException: 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
Source Error:
Line 90: Line 91: Line 92: smtp.Send(msg) Line
93: Session("isFromCheck") = "yes"
Source File:
h:\root\home\subhankarjana-001\www\alumnifeedback\check.aspx.vb
Line: 92
I am trying to test sending out an e-mail from vb.net. I am sending an e-mail from mygmail account to myself, however I keep getting an error message: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
Dim SmtpServer As New SmtpClient("smtp.gmail.com", 587)
SmtpServer.EnableSsl = True
SmtpServer.Credentials = New Net.NetworkCredential("MYEMAILADDRESS", "MYPASSWORD")
Dim mail As New MailMessage("MYEMAILADDRESS", "MYEMAILADDRESS", "This is my Title", "This is my Email")
SmtpServer.Send(mail)
I have read a few post but all of them say change the port. I have changed the port however it doesn't seem to work. If I change the port it gives a similar error.
Here is the code I have to send the email:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Try
Dim SmtpServer As New SmtpClient
SmtpServer.EnableSsl = True
Dim mail As New MailMessage
SmtpServer.Credentials = New Net.NetworkCredential("Frrizzeh#gmail.com", "Password here")
SmtpServer.Port = "587"
SmtpServer.Host = "smtp.gmail.com"
mail = New MailMessage
mail.From = New MailAddress("Frrizzeh#gmail.com")
mail.To.Add("Frrizzeh#gmail.com")
mail.Subject = TextBox1.Text
mail.Body = TextBox2.Text
SmtpServer.Send(mail)
Catch ex As Exception
MsgBox(ex.Message)
End Try
However when I run the program it just returns this error:
The SMTP server requires a secure connection or the client was not authenticated.
The server server response was: 5.5.1 Authentication required.
Any ideas where I am going wrong?
Try enabling less secure password from: https://www.google.com/settings/security/lesssecureapps so you can login from your app.
Also, try adding the following properties
SmtpServer.DeliveryMethod = SmtpDeliveryMethod.Network
SmtpServer.UseDefaultCredentials = False
You might have two step verification enabled and if so you need to generate an app specific password for you to use. Ive answered this and provided code in another question like this before. See link below...
Fail Sending Email Unable To Connect the Remote Server
I had this problem and fixed it by changing my gmail password to a stronger one with upper, lower, symbol, numeric.
It was funny that it worked fine from localhost but failed from my server.
I am using the Following Code for my GMAIL Server SMTP Settings, but am unable to send emails.
Can anyone help me out...
Dim emailClient As New SmtpClient("mail.gmail.com")
Dim SMTPUserInfo As New System.Net.NetworkCredential("xxxxx#gmail.com", "abc123")
emailClient.UseDefaultCredentials = False
emailClient.Port = 465
emailClient.EnableSsl = True
emailClient.Credentials = SMTPUserInfo
emailClient.Timeout = 1000000
emailClient.Send(mail)
emailClient = Nothing
SMTPUserInfo = Nothing
Catch ex As Exception
MessageBox.Show(ex.Message & " Error Mails : ", Me.Text, MessageBoxButtons.OK)
End Try
I think, you should use following settings:
emailClient.Host = "smtp.gmail.com"
emailClient.port = 587
emailClient.EnableSsl = True
If you connect using SMTP, you can only send mail to Gmail or Google Apps users; if you connect using SSL/TLS, you can send mail to anyone. If your device or application supports SSL - connect to smtp.gmail.com on port 465. To connect with SSL, you need to provide a Google username and password for authentication.
Source: https://support.google.com/a/answer/176600?hl=en
i have the following code,i'm trying to send an email from my windows application but it's not working... any help ? note that i'm using vb.net and i'm not getting any errors.. i'm just not receiving any emails !
Private Sub senemail()
'create the mail message
Dim mail As New MailMessage()
'set the addresses
mail.From = New MailAddress("jocelyne_elkhoury#inmobiles.net")
mail.To.Add("jocelyne_el_khoury#hotmail.co.uk")
'set the content
mail.Subject = "This is an email"
mail.Body = "this is a sample body"
'send the message
Dim smtp As New SmtpClient("127.0.0.1")
smtp.Send(mail)
End Sub
In my experience, sending email via .net (and vb6 before it) is weird. Sometimes it should work and just doesn't, sometimes because of .net bugs and sometimes incompatibility with the smtp server. Here is some code that works on VB 2008, and it should work with 2010.
Using msg As New MailMessage(New MailAddress(fromAddress, fromName), New MailAddress(toAddress))
Try
Dim mailer As New SmtpClient
msg.BodyEncoding = System.Text.Encoding.Default
msg.Subject = subject
msg.Body = body
msg.IsBodyHtml = False
mailer.Host = mailserver
mailer.Credentials = New System.Net.NetworkCredential(username, password) ' may or may not be necessary, depending on the server
mailer.Send(msg)
Catch ex As Exception
Return ex.Message
End Try
End Using ' mailmsg
If this doesn't work, try using localhost instead of 127.0.0.1 for the mailserver.
If that doesn't work, try using your system name (the one that shows up on the network) for the mailserver.
If that doesn't work, try using an external smtp server with your own username and password (just for testing).
profit.