|Re: [mail-dev] Request for enhancement - Show transport protocol version|
Hi Rob, There are public methods that you can query to determine this information. You need to have access to a Transport, Message, or Session in order to invoke them. A transport is a type of service so all you need to do is gain access to the Transport used to send the message. If you don't have a transport then you need to gain access to a Session that is used to create a transport. Message and MessageContext can gain access to the session assigned to a MimeMessage. Once you have access to the Session you need to call one of the getTransport methods. If you are using the static Transport::send the you need to emulate the transport lookup rules in : https://github.com/eclipse-ee4j/mail/blob/master/mail/src/main/java/jakarta/mail/Transport.java#L217 Now there is no service query method that determines if implementation is secure. However, there are query methods that don't require resorting to reflection. They are: 1. Inspect Service::getURLName (https://eclipse-ee4j.github.io/mail/docs/api/javax/mail/Service.html#getURLName--) to see if the transport is secure. 2. Check the type of the transport. If you are not using a custom transport the secure transport class contains SSL in the class name. Jason ________________________________________ From: mail-dev-bounces@xxxxxxxxxxx <mail-dev-bounces@xxxxxxxxxxx> on behalf of Rob Griffin (rgriffin) <Rob.Griffin@xxxxxxxxx> Sent: Thursday, August 27, 2020 7:29 PM To: mail-dev@xxxxxxxxxxx Subject: [mail-dev] Request for enhancement - Show transport protocol version Hi, We are using currently using JavaMail in our application (Spotlight on SQL Server Enterprise) but will be switching to Jakarta Mail shortly. We want to warn users when they are using an insecure protocol to send email. We are planning to use reflection to discover which protocol is being used but that is a very hacky way to find this out. Would it be possible to add a method to the API to show the transport protocol and version? Regards, Rob Griffin Software Analyst, Spotlight on SQL Server Quest | R&D rob.griffin@xxxxxxxxx<mailto:rob.griffin@xxxxxxxxx> ?
Back to the top