I'm revising code I did not write that uses JavaMail, and having a little trouble understanding why the JavaMail API is designed the way it is. I have the feeling that if I understood, I could be doing a better job.
We call:
transport = session.getTransport("smtp");
transport.connect(hostName, port, user, password);
So why is Eclipse warning me that this:
transport.send(message, message.getAllRecipients());
is a call to a static method?
Why am I getting a Transport object and providing settings that are specific to it if I can't use that object to send the message? How does the Transport class even know what server and other settings to use to send the message? It's working fine, which is hard to believe. What if I had instantiated Transport objects for two different servers; how would it know which one to use?
In the course of writing this question, I've discovered that I should really be calling:
transport.sendMessage(message, message.getAllRecipients());
So what is the purpose of the static Transport.send() method? Is this just poor design, or is there a reason it is this way?