Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The below code does not successfully send the email message using yahoo smtp server.


Dim eMSG As New MailMessage

eMSG.From = New MailAddress(<from addr>)
eMSG.To.Add("kevin.brady.az@gmail.com")
eMSG.Subject = "Hello - Test Message"
eMSG.Body = "Test123 Test123"
Dim SMTP As New SmtpClient("smtp.mail.yahoo.com")
SMTP.Port = 465
SMTP.EnableSsl = True
SMTP.Credentials = New System.Net.NetworkCredential(<username>, <pwd>)

Try
    SMTP.Send(eMSG)
    MsgBox("Your Mail has been Successfully sent")

Catch ex As Exception
    MsgBox(ex.ToString)

End Try


The following exception is reported: System.Net.Main.SmtoExceptions: Failure sending mail ---> System.FormatException: Smtp server returned an invalid response....

I have also had similiar problems trying to use gmail.

What I have tried:

Reviewed many posts online about using Yahoo SMTP mail.

Tried using different port settings.

Cannot figure-out how to "enable less secure apps" in yahoo settings
Posted
Updated 19-Jan-23 12:19pm
Comments
Richard MacCutchan 20-Jan-23 4:06am    
Try port 587.
Kevin Brady 21-Jan-23 11:41am    
Port 587 worked in conjunction with setting an application specific password in Yahoo.

1 solution

A lot of the time, tasks that are common are usually documented somewhere on the internet, like a blog.

I did a quick google search for vb how to send email via yahoo[^] and found the following:
* Send Email using Yahoo in VB.NET[^]
* Send Mail Using Gmail, Yahoo Account in VB.Net and C#.Net[^]

Both of these articles have working solutions.

Enjoy!
 
Share this answer
 
Comments
Kevin Brady 21-Jan-23 11:40am    
Before posting this question, I did a google search for the issue. I found both of the above links as well as many others similar ones. None of them worked.

Yahoo mail and gmail have changed the method to programmatically access email services.

See this link: https://stackoverflow.com/questions/62030011/allow-less-secure-app-access-in-yahoo-mail

In Yahoo email, I had to generate an application specific password. After doing this, the solution was able to send emails.

Also, I had to change the port to 587.
Graeme_Grant 21-Jan-23 16:31pm    
In the first link that I provided it did say:

"If you got authentication error, you need to enable Allowing less secure apps in your Yahoo account. Or you can generate App Passwords and use this app password instead of your user password.

Although Yahoo supports OAUTH, but it doesn’t provide mail permission, so OAUTH is not a solution for Yahoo mail."

And also had the following example:

"[VB.NET - Send Email using Yahoo over Explicit SSL (TLS) on 25 or 587 Port - Example]?

Glad that you are sorted.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900