[
https://issues.apache.org/jira/browse/EMAIL-128?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Thomas Neidhart reopened 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