dcsimg
When I set the system properties to my smtp host more than once the smtp host is the to localhost. Why?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   fernando_fernandes
Posted On:   Wednesday, June 6, 2001 06:43 AM

I have a program that have multiple threads sending mails. When the first thread set the session propertie to set the smtp host to the host I want it works fine. But in the secont time it is set to local host. This is the part of the code that set´s it:

props = System.getProperties();
props.put("mail.smtp.host","myhost");
session = Session.getDefaultInstance(props, null);

First time the host is "myhost", second time the host is "localhost". Why?

Re: When I set the system properties to my smtp host more than once the smtp host is the to localhost. Why?

Posted By:   Ignacio_Conejo  
Posted On:   Monday, June 25, 2001 09:10 AM

I had the same problem and I fixed it doing this:
Do not use session.getDefaultInstance(); use instead ssesion.getInstance(). It seems like there is a problem with the session the second time you try to use it or set properties.
If that fails to work, try not using Transport.send(). Use :
message.saveChanges();
Transport transport =session.getTransport("smtp");
transport.connect(serv, user, pass);
transport.sendMessage(message,message.getAllRecipients());
transport.close();
I hope this should help you. Bye
About | Sitemap | Contact