-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SecureSocket.connect
throws HandshakeException: WRONG_VERSION_NUMBER
#52886
Comments
SecureSocket
throws HandshakeException: WRONG_VERSION_NUMBER
SecureSocket.connect
throws HandshakeException: WRONG_VERSION_NUMBER
Same error here using mailer. @rubenferreira97 as you closed the issue as completed, can you share the solution you found? I was thinking that maybe Dart doesn't support the latest TLS protocols. Or maybe Dart delegates it to the OS... but still is weird because I'm testing it on a fresh latest Raspberry OS (Debian 12). UPDATE I:It is really strange. I tested with https://www.checktls.com/TestReceiver and my SMTP server seems to work fine: The error that I get on the SMTP server (Postfix) when executin Dart's mailer is:
UPDATE II:This simple Dart code fails with the same output so I'm pretty sure that Dart is not supporting latest version of TLS, as a simple import 'dart:io';
void main(List<String> arguments) async {
final socket = await SecureSocket.connect('example.com', 587);
await Future.delayed(const Duration(seconds: 10));
await socket.close();
}
UPDATE III:Executing plain
|
Hey @busslina I will be honest, I forgot how I solved the problem. I am almost sure that it was a problem on my end. I am looking at the old code and this is working for me: import 'package:mailer/mailer.dart';
import 'package:mailer/smtp_server.dart';
void main() async {
final address = Address('youremail@email.com', 'YourEmailName');
final smtpServer = SmtpServer(
'yourhost',
port: 587,
name: address.name,
username: address.mailAddress,
password: 'yourpassword',
);
final message = Message()
..from = address
..recipients.addAll(['to@tempmail.com'])
..subject = 'Test'
..text = 'Test'
..html = 'Test';
await send(message, smtpServer);
} What's your dart version? I don't know if it's the case but sometimes exceptions are reported by the IDE but they are handled internally (if you use VSCode check if |
@rubenferreira97 thanks. I updated my previous message.
3.3.3 (not latest but close)
I'm not executing it with VSCode. As I posted in my previous message: It's really strange that a simple If you solved it, maybe you changed your SMTP server configuration to allow lower TLS versions. |
In your code seems that your solution was to disable TLS, as it's disabled by default on mailer. So this could be a mailer issue. Gonna report it. |
@busslina I reopened the issue for further investigation. It seems the default options are all good ( |
@rubenferreira97 Thanks You can see here that what matters to select between |
TL;DR: Don't use There are 2 ways to send mails over secure connections:
In your screenshot we are waiting for the response to get list of capabilities. That's also the reason for the 2 different exceptions. If we don't get a response at all, it is possible, that we should have used an The openssl command shows that we should use |
@busslina ☝️ Now that I remember, this was the conclusion that I got. At the time, I inspected/debugged more careful and checked the logs of my SMTP server. It was indeed upgraded to a secure connection. |
Thanks both :) |
I am using Dart on the server and trying to send an email by connecting and authenticating to a SMTP server using TLS (let's say
mail.myserver.com
on port 587) with the package mailer. After setting everything up correctly (as far as I know), aHandshakeException
is thrown here.After some debugging and attempting to isolate the problem, I wrote the following script that simply connects to a secure host:
The following error is thrown:
Changing the port from
587
to465
printsConnected!
.For testing purposes, I tried the following commands on the same machine where I executed the previous Dart script:
Using the
telnet smtp.gmail.com 587
command incmd
(Windows) successfully connects and outputs:Using the
telnet smtp.gmail.com 465
andtelnet google.com 443
commands also connect successfully.Is this a bug or am I missing something?
The text was updated successfully, but these errors were encountered: