Fix issue with smtp and STARTTLS/SMTPS #494
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #519
We used starttls by setting mail.smtp.starttls.enable=true in advanced settings. After 579c6ab it started failing.
I wen't on and checked the new code. I'm not a programmer, but I think that with this piece of code, the advanced settings that are behind this try block will never run when using plain text SMTP.
I noticed also that if it was set to use START_TLS, it would also set SSL properties, which is wrong also.
It must be SSL (usually on port 465) or StartTLS (usually port 587). Never both.
As I'm not a programmer, I'm not sure that the small changes that I did are the correct approach for this issue but I tested and it worked for every scenarios that I thought would be more common as:
Plain SMTP with advanced mail.smtp.starttls.enable=true (As I was using before)
Plain SMTP with no starttls (usual no encryption, port 25, with auth).
SMTPS (with auth)
START_TLS (with auth)
Only scenarios that I didn't test are without authentication. But my patch didn't touch that.