A strange issue with STARTTLS

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.
Post Reply
DrmCa
Normal user
Normal user
Posts: 81
Joined: 2011-02-14 21:30

A strange issue with STARTTLS

Post by DrmCa » 2020-10-19 03:28

I am writing a piece of software in c#.net that among other things has to send emails.
To prototype it quickly, I used SmtpClient, which only supports STARTTLS. I added a new port to my server:

Protocol SMTP,
IP 0.0.0.0,
Port 587,
Security STARTTLS(optional),
with the same cert as port 465.

Restarted the server and fired up the app. In the code, I set port to 587, EnableSsl = true, SecurityProtocol = tls1.2 (tried ssl3 as well)
Unfortunately, SmtpClient class still cannot connect. It throws an error that says that "Remote server replied: Must issue STARTTLS first."
Is anything missing in my port configuration?

palinka
Senior user
Senior user
Posts: 2178
Joined: 2017-09-12 17:57

Re: A strange issue with STARTTLS

Post by palinka » 2020-10-19 03:44

Sorry, I don't have a solution for you, but this happens when TLS is required from the beginning by the client. StartTLS on 587 first connects unencrypted and then upgrades the connection to TLS. 465 starts the connection with TLS (no unencrypted connection/upgrade). Your client is going in hot (encrypted). Hope this helps you find your issue.

DrmCa
Normal user
Normal user
Posts: 81
Joined: 2011-02-14 21:30

Re: A strange issue with STARTTLS

Post by DrmCa » 2020-10-19 04:14

I have to make a correction to the above: the error in the OP appeared when the port was set to STARTTLS(required).
Since I changed it to (optional) the error changed:

{"Unable to read data from the transport connection: net_io_connectionclosed."}

User avatar
mattg
Moderator
Moderator
Posts: 21106
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: A strange issue with STARTTLS

Post by mattg » 2020-10-19 04:28

I've found that despite the terms StartTLS being used
DrmCa wrote:
2020-10-19 03:28
To prototype it quickly, I used SmtpClient, which only supports STARTTLS. I added a new port to my server:

Protocol SMTP,
IP 0.0.0.0,
Port 587,
Security STARTTLS(optional),
with the same cert as port 465.

In the code, I set port to 587, EnableSsl = true, SecurityProtocol = tls1.2 (tried ssl3 as well)
Try port 465 in SMTPClient with EnableSSL = True, OR(This will likely be SSL/TLS in Hmailserver parlance)
Try port 587 in SMTPClient with EnableSSL set to false, but still set TLS to v1.2 or 1,3 (This will likely be StartTLS)

This works for me with some Java software that sends emails.
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

DrmCa
Normal user
Normal user
Posts: 81
Joined: 2011-02-14 21:30

Re: A strange issue with STARTTLS

Post by DrmCa » 2020-10-19 21:07

I got tired of SmtpClient issues and moved on to MailKit which works fine.
This will go down as another mystery, because I used to connect to hMailServer successfully at another site, but it was over port 25 only.

Post Reply