commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ivan Melnikov (JIRA)" <>
Subject [jira] [Created] (EMAIL-128) HtmlEmail doesn't close connection to smtp server
Date Sun, 21 Jul 2013 02:38:48 GMT
Ivan Melnikov created EMAIL-128:

             Summary: HtmlEmail doesn't close connection to smtp server
                 Key: EMAIL-128
             Project: Commons Email
          Issue Type: Bug
    Affects Versions: 1.3.1
            Reporter: Ivan Melnikov
            Priority: Blocker


I tried to send html email to smtp server from my GWT application servlet by using this official
site user guide example the
"HtmlEmail" usage snippet...

Sending message with smtp requires authentication and encryption so I combined two examples
and used code like a (see my snippets)

snippet A : 
public class Send{

public synchronized SendReport send(MyMessage msg){
// Create the email message
		  HtmlEmail email = new HtmlEmail();
		  try {
			  email.setAuthenticator(new DefaultAuthenticator(USER_NAME,PASSWORD));
			  email.addTo(TO, "test");//send to me...
//			  email.addTo(msg.getEmail());//send notification...
			  email.setFrom(FROM, msg.getFrom());
			  String message=msg.getMessage();

			  // set the alternative message
			  email.setTextMsg("Your email client does not support HTML messages");

			  // send the email
		} catch (EmailException e) {
			// TODO Auto-generated catch block
}//method end...
}//class end...

snippet B: the gwt/rpc servlet 	

public class SendServiceImpl extends RemoteServiceServlet implements SendService {

	static Send send=new Send();
	public SentReport sendMessage(MyMessage message) {
		return this.getMessageSend().sendMessage(message);
	private synchronized Send getSend()
		return this.send;


***Problem description:

Message sending works fine and I can see email in my inbox; The problem occurs when I stop
Tomcat and close the web application browser tab (FF for example); for some reason right after
that my web browser (FireFox) cannot download web pages (throws connection timeout error...)
though Internet connection is working fine :S I tried to download web pages with another internet
browser Chrome for example but it behaves all the same :( I tried to see opened ports with
"netstat -an" cmd and it shows me a long list of opened ports (which I don't have until send
email code as "email.send();" activated...); That makes me think that for some reason the
JavaMail connection to smtp server is NOT CLOSED or something similar?
The problem disappears only after I restart my OS (Windows XP Pro SP3);  

So I suspect some bug which prevents smtp server connection closing after message send; I
cannot say for sure but maybe socket connection doesn't close after message has been sent
and received... I am not sure what should I add to my code to solve the problem because I
followed all user guide examples which don't show how to close smtp server connection manually
or something so I am a confused how to fix it :( Maybe it is some kind of memory leak due
to JavaMail I don't know...

I dearly need your help because it is quite complicated issue as for me that makes impossible
to use HtmlEmail class in my gwt application (its server side code)

***My project uses

- IDE : Eclipse Indigo 3.7
- GWT SDK 2.3
- JavaMail API 1.4.5
- commons-email-1.3.1
- Tomcat 7/ Jetty - in eclipse
- JRE: version 7 Update 25 build 1.7.0_25-b17
- OS: Windows XP Pro SP3

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message