javax.mail.MailingException: already connected
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ajay_Tejwani
Posted On:   Wednesday, May 9, 2001 09:44 AM

I am getting the above exception, the code is as under, as given by you in the tutorial:-

message.saveChanges();
Transport transport = session.getTransport("smtp");
transport.connect(pop3, username, password);
transport.connect(host, username, password);
transport.sendMessage(message, message.getAllRecipients());
transport.close();

when I comment out transport.connect(host, username, password); it works fine. Does it mean that the connection is still maintained with the mail server even after using the close method. How can it be overcome. Thanks,

Re: javax.mail.MailingException: already connected

Posted By:   Michael_Wax  
Posted On:   Wednesday, May 9, 2001 08:28 PM

You are connecting the Transport twice. The documentation for the Service classes (Store and Transport) specifies that they should throw an exception if their connect method is invoked when they are already connected. (You did not do invoke close between the two connects.) The second connect is unnecessary at best. As you note, commenting it out will make your code work.
About | Sitemap | Contact