Make getTransport in JavaMailSender public in order to allow inspecting which port is being used when none was specified.

SMTP has multiple default ports, depending on configuration. Most commonly 25 vs. 587.

  • use case: https://github.com/spring-projects/spring-boot/issues/35247

Comment From: sbrannen

Instead of making getTransport(Session) public, we propose to introduce a public getActualPort() method in JavaMailSenderImpl to address this.

Comment From: sbrannen

It appears that we may not be able to reliably determine the actual port used.

  • see https://github.com/spring-projects/spring-boot/issues/35247#issuecomment-1561180315

We will continue investigating our options.

Comment From: sbrannen

It appears that we may not be able to reliably determine the actual port used.

That turns out to be the case. In light of that I am closing this issue.