Secure CURLEmailMBS works only when OptionPort is not set!

I have spent hours trying to send secure emails via CURLEmailMBS using both my own application and MBS’ example programs. I have been successful in sending emails as:
• unsecured port 25 and port 2525 via my host
• secured via iCloud’s application-specific password on port 587

but I couldn’t get it to work with my host’s secured port 465. I tied every combination of URL (appending ‘:465’) and setting on/off dozens of options. The only way I know of forcing the SMTP port number is:

tempUploadCURLSMTP.OptionPort = 465

Nothing was working. Out of frustration I commented out this line and the ‘:465’ in the URL and to my surprise it worked! I’m not sure how, since it doesn’t know the SMTP port number. Does CURL guess it, or somehow determine it? Just thought you’d like to know!

port 465 expects SSL connection from start.
But maybe you asked for TLS v1.2?

because TLS starts with an unencrypted connection and later uses encryption.
But that only works with 25 and 587 ports.

What confuses me is why setting the port number through OptionPort causes SMTP to stop working!

Of course.
If you connect with TLS to a SSL only connecting, the one talks plain text and the other one encrypted and that won’t work.

Then how should we set the port number when using TLS?

Are you suggestion that:

  1. if you are using TLS then don’t set the port number
  2. if you are using SSL then you must set the port number

TLS or unencrypted is 25 or 587.
SSL is 465.