MailSender doesn't correctly set JavaMail properties for SMTPS connections
cbarcenas opened this issue · 6 comments
Several of the configuration methods in MailSender
incorrectly set JavaMail properties under the mail.smtp
prefix when smtps
mail transport (TransportStrategy.SMTP_SSL
) is used. I'm pretty sure the mail.smtps
prefix should be used instead.
The cleanest fix, I think, is to implement additional abstract property name getters under the TransportStrategy
enum.
Indeed, quoting javaee:
Note that if you're using the "smtps" protocol to access SMTP over SSL, all the properties would be named "mail.smtps.*".
I agree, these properties will need to come from the TransportStrategy
enum. Strange that I overlooked this. Let's fix this asap.
Now that I think about it, why don't we scrap the per-property interface and instead add a single propertyNamePrefix()
method to each enum type?
I like the flexibility it gives me in case the property is completely different per transport strategy. Of course this will never happen with this decades old specification, so it is kind of moot.
However, I like this design, it's clear enough (and I've already updated it).
Cool, I'm pretty indifferent either way
Actually, this was rather tricky, since the transport strategy is an optional parameter in favor of a preconfigured provided Session object.
In one type of scenario an exception was in order, in a second skipping defaults and in a third skipping properties logging they were assumed to be preconfigured.
Released as 5.0.0.rc1-SNAPSHOT. Add OSS' snapshots repo to find it in Maven.