Why does my JTS show services hanging in MailerService.sendMessage()?
One answer
If MailService calls are visibly queuing up and taking several minutes to be processed then there is a potential problem since these calls could potentially prevent license requests for new client connections.
There are several possible causes of this including a bad SMTP configuration, however if emails are eventually sent then you should look the details of the waiting service calls and see if any of them include a call to SMTPTransport.isConnected.
If this code is frequently hit then you may be encountering a situation where JTS is trying to keep an SMTP connection open by sending NOOP messages which is known to interact with some firewall configurations designed to defeat denial of service attacks.
If this is the case there are two possible workarounds, one is to change the network configuration so that it no longer reacts to frequent NOOP messages. This approach however may not be approved by corporate IT standards.
The second workaround is to reduce reuse of the SMTP connection by setting "Transport Reuse Count" in the JTS mail configuration to 5(the default is 19).