I’m trying to test code to send an email. The code I have is this:
Var email As New EmailMessage
email.FromAddress = "address@yahoo.com" ' real e-mail address, not this one
email.AddRecipient("address@yahoo.com") ' real e-mail address, not this one
email.Subject = "Teste e-mail"
email.BodyPlainText = "I hope it works!!"
email.Headers.AddHeader("X-Mailer","SMTP Test")
MailSocket.Address = "smtp.mail.yahoo.com"
MailSocket.Port = 465
MailSocket.SSLConnectionType = SSLSocket.SSLConnectionTypes.TLSv1
MailSocket.SMTPConnectionType = SMTPSecureSocket.SMTPConnectionTypes.SSLTLS
MailSocket.SSLEnabled = True
MailSocket.Username = "my_yahoo_address@yahoo.com" ' my actual address not this one, of course
MailSocket.Password = "kdsjfajhskjfhdlog" ' the application password generated by Yahoo!
MailSocket.Messages.AddRow(email)
MailSocket.SendMail
But what I get, after a few seconds of executing the code is an “Unable to resolve address” error.
What am I doing wrong?
If you get an IP address when you ping the URL, then ping resolves the address. Since your workstation can resolve the address (there is no firewall or other external issue preventing the resolution of the address), something in your program seems to be causing the issue. Now, what is the issue is the big question… Here are just a few ideas:
Are you sure that you do have the correct application password?
Is the password restricted to a specific web address? (for example, my google Places API calls don’t work in the IDE, but once the application is compiled and accessed through it’s public URL, they work just fine. My API key is restricted to that web adderess. My choice.)
are you using the correct ports to connect?
Is Yahoo restricting the version of TLS that can be used to connect? - I would suggest to try with version 1.2 or 1.3. I believe that they deprecated V1 a while back.
I don’t see that you offer STARTTLS in your code. I believe that Yahoo requires it. Not too sure because I don’t use Yahoo, but I remember seeing something about it somewhere.
There are many other such reasons that could cause the error.
Actually, when I first tested it, I was in my work and I believe there is a firewall there.
It worked at home.
So, assuming there is a firewall, what type of actions can be taken?
Var e As New CURLEmailMBS
e.SetFrom "my_yahoo_address@yahoo.com", "christian Müller"
e.Subject = "Hello World ☺️"
e.SMTPPassword = "kdsjfajhskjfhdlog"
e.SMTPUsername = "my_yahoo_address@yahoo.com"
e.SetServer "smtp.mail.yahoo.com", True
e.AddTo "christian@mobkeybreadsoftware.de", "Christian Schmitz"
e.PlainText = "Hello World," + EndOfLine + "Smilies: ☺️ 😘 😄"
Var c As New CURLSMBS
If c.SetupEmail(e) Then
Var er As Integer = c.Perform
If er = 0 Then
MsgBox "Email sent"
Else
Var Log As String = c.DebugMessages
Break
End If
end if
this will show a log like this:
MBS Xojo Plugins 25.3 with CURL 8.14.1 on macOS.
URL: smtps://smtp.mail.yahoo.com
Host smtp.mail.yahoo.com:465 was resolved.
IPv6: (none)
IPv4: 87.248.97.36
Trying 87.248.97.36:465…
TLSv1.3 (OUT), TLS handshake, Client hello (1):
TLSv1.3 (IN), TLS handshake, Server hello (2):
TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
TLSv1.3 (IN), TLS handshake, Certificate (11):
TLSv1.3 (IN), TLS handshake, CERT verify (15):
TLSv1.3 (IN), TLS handshake, Finished (20):
TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
TLSv1.3 (OUT), TLS handshake, Finished (20):
SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256 / x25519 / RSASSA-PSS
Server certificate:
subject: C=US; ST=New York; L=New York; O=Yahoo Holdings Inc.; CN=smtp.mail.yahoo.com
start date: May 20 00:00:00 2025 GMT
expire date: Nov 12 23:59:59 2025 GMT
issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 High Assurance Server CA
SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
Certificate level 0: Public key type RSA (2048/112 Bits/secBits), signed using sha256WithRSAEncryption
Certificate level 1: Public key type RSA (2048/112 Bits/secBits), signed using sha256WithRSAEncryption
Connected to smtp.mail.yahoo.com (87.248.97.36) port 465
TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
220 smtp.mail.yahoo.com ESMTP ready
EHLO MyMacM3
250-hermes–production-ir2-858bd4ff7b-bdxql Hello MyMacM3 [185.231.254.186])
250-PIPELINING
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-SIZE 41697280
250 AUTH PLAIN LOGIN XOAUTH2 OAUTHBEARER
AUTH PLAIN
334 UGxhaW46
AG15X3lhaG9vX2FkZHJlc3NAeWFob28uY29tAGtkc2pmYWpoc2tqZmhkbG9n
535 5.7.0 (#AUTH005) Too many bad auth attempts.
closing connection #0
Which provides more details.
So we find an IP here, we can connect, greet server and come to the login where the account is blocked.