Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0C2E710CD7 for ; Wed, 24 Jul 2013 00:26:48 +0000 (UTC) Received: (qmail 47679 invoked by uid 500); 24 Jul 2013 00:26:48 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 47610 invoked by uid 500); 24 Jul 2013 00:26:48 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 47601 invoked by uid 99); 24 Jul 2013 00:26:48 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Jul 2013 00:26:48 +0000 Date: Wed, 24 Jul 2013 00:26:48 +0000 (UTC) From: "Ivan Melnikov (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Closed] (EMAIL-128) HtmlEmail doesn't close connection to smtp server MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/EMAIL-128?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Ivan Melnikov closed EMAIL-128. ------------------------------- > HtmlEmail doesn't close connection to smtp server > ------------------------------------------------- > > Key: EMAIL-128 > URL: https://issues.apache.org/jira/browse/EMAIL-128 > Project: Commons Email > Issue Type: Bug > Affects Versions: 1.3.1 > Reporter: Ivan Melnikov > Priority: Blocker > Fix For: 1.3.1 > > > ***Prehistory: > I tried to send html email to smtp server from my GWT application servlet by using this official site user guide example http://commons.apache.org/proper/commons-email/userguide.html 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.setHostName("smtp.mail.com"); > email.setSmtpPort(465); > email.setAuthenticator(new DefaultAuthenticator(USER_NAME,PASSWORD)); > email.setSSLOnConnect(true); > > email.addTo(TO, "test"); > > email.setFrom(FROM, msg.getFrom()); > email.setSubject(msg.getSubject()); > > String message=msg.getMessage(); > > email.setHtmlMsg(message); > email.setTextMsg("Your email client does not support HTML messages"); > email.send(); > > > } catch (EmailException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > > > } > }//method end... > }//class end... > ------------------------------------ > snippet B: the gwt/rpc servlet > public class SendServiceImpl extends RemoteServiceServlet implements SendService { > static Send send=new Send(); > > @Override > 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: http://www.atlassian.com/software/jira