0

I am using Apache commons mail to send mail in my web application. My web application is hosted in Tomcat. When I try to send mail for the first time after server starts. I am able to send mail. But after that, when I attempted second time, it is not connecting to SMTP port 25.

By using setDebug(true);, I could able to find that after emailObj.send(), it closes the connection. So then it couldn't connect next time.

How to resolve my issue?

skaffman
  • 398,947
  • 96
  • 818
  • 769
Manoj
  • 5,707
  • 19
  • 56
  • 86

1 Answers1

1

Are you reusing the same Email instance ?

Email is a class representing one Email, which you will sent through send() method.

If you want to send another email, you have to instantiate a new Email object.

Tanguy
  • 191
  • 1
  • 6
  • No. I am creating HtmlEmail object locally inside the method. So for every invocation, it should be creating new one. So i am not reusing the same instance. – Manoj Mar 31 '11 at 07:21
  • Sorry. Actually for some other purpose, i have set proxy settings. That blocked the port. It is working fine.Thanks for your responses – Manoj Mar 31 '11 at 09:25