geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick McGuire <rick...@gmail.com>
Subject Re: javax.mail.MessagingException: .. could not connect to SMTP host -Reg
Date Thu, 22 Feb 2007 10:20:08 GMT
There's a bug in the code that sorts out the connection host when you 
are using Transport.send(). There are two workarounds I know of for the 
problem:

1) set the target SMTP host using the "mail.host" property rather than 
"mail.smtp.host", or
2) Rather than use Transport.send(), explicitly request a transport 
instance from the Session and call connect() yourself, passing in the 
appropriate target and port.

It also appears from the Exception getting thrown and the stack trace, 
that your application is picking up the Sun mail.jar, resulting in 
mixing of the Geronimo mail api code with the Sun SMTPTransport 
implemenation. This should, in theory, work, but is not a configuration 
we've doing any testing with at all. You should remove any dependency 
you have on the sun mail.jar and make sure you're picking up the 
geronimo-javamail-transport jar included with 1.1.1.

Rick

Kamalanathan Raman wrote:
>
> Hi ,
>
> Iam trying to send a notification mail using the java mail in Geronimo 
> 1.1.1 . When I try to send the mail iam getting this following 
> exception , can any one give a pointer regarding where iam going wrong 
> and what to do…
>
> _javax.mail.SendFailedException_: Send failure 
> (_javax.mail.MessagingException_: Could not connect to SMTP host: 
> localhost, port: 25 (_java.net.ConnectException_: Connection refused: 
> connect))
>
> at javax.mail.Transport.send(_Transport.java:161_)
>
> at javax.mail.Transport.send(_Transport.java:46_)
>
> at com.symcor.common.util.SendMail.sendNotification(_SendMail.java:171_)
>
> at com.symcor.common.util.SendMail.sendNotification(_SendMail.java:92_)
>
> at com.symcor.eds.app.RunEDSService.sendMail(_RunEDSService.java:411_)
>
> at com.symcor.eds.app.RunEDSService.main(_RunEDSService.java:338_)
>
> Caused by: _javax.mail.MessagingException_: Could not connect to SMTP 
> host: localhost, port: 25 (_java.net.ConnectException_: Connection 
> refused: connect)
>
> at com.sun.mail.smtp.SMTPTransport.openServer(_SMTPTransport.java:867_)
>
> at 
> com.sun.mail.smtp.SMTPTransport.protocolConnect(_SMTPTransport.java:156_)
>
> at javax.mail.Service.connect(_Service.java:215_)
>
> at javax.mail.Service.connect(_Service.java:83_)
>
> at javax.mail.Service.connect(_Service.java:68_)
>
> at com.sun.mail.smtp.SMTPTransport.connect(_SMTPTransport.java:93_)
>
> at javax.mail.Transport.send(_Transport.java:92_)
>
> ... 5 more
>
> Caused by: _java.net.ConnectException_: Connection refused: connect
>
> at java.net.PlainSocketImpl.socketConnect(_Native Method_)
>
> at java.net.PlainSocketImpl.doConnect(Unknown Source)
>
> at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
>
> at java.net.PlainSocketImpl.connect(Unknown Source)
>
> at java.net.SocksSocketImpl.connect(Unknown Source)
>
> at java.net.Socket.connect(Unknown Source)
>
> at java.net.Socket.connect(Unknown Source)
>
> at java.net.Socket.<init>(Unknown Source)
>
> at java.net.Socket.<init>(Unknown Source)
>
> at com.sun.mail.util.SocketFetcher.getSocket0(_SocketFetcher.java:131_)
>
> at com.sun.mail.util.SocketFetcher.getSocket(_SocketFetcher.java:113_)
>
> at com.sun.mail.smtp.SMTPTransport.openServer(_SMTPTransport.java:836_)
>
> ... 11 more
>
> 2007-02-22 14:50:47,674 INFO com.symcor.common.util.SendMail 
> -sendNotification(...):exit
>
> 2007-02-22 14:50:47,674 ERROR root -main[]:Send failure 
> (_javax.mail.MessagingException_: Could not connect to SMTP host: 
> localhost, port: 25 (_java.net.ConnectException_: Connection refused: 
> connect))
>
> _javax.mail.SendFailedException_: Send failure 
> (_javax.mail.MessagingException_: Could not connect to SMTP host: 
> localhost, port: 25 (_java.net.ConnectException_: Connection refused: 
> connect))
>
> at javax.mail.Transport.send(_Transport.java:161_)
>
> at javax.mail.Transport.send(_Transport.java:46_)
>
> at com.symcor.common.util.SendMail.sendNotification(_SendMail.java:171_)
>
> at com.symcor.common.util.SendMail.sendNotification(_SendMail.java:92_)
>
> at com.symcor.eds.app.RunEDSService.sendMail(_RunEDSService.java:411_)
>
> at com.symcor.eds.app.RunEDSService.main(_RunEDSService.java:338_)
>
> Caused by: _javax.mail.MessagingException_: Could not connect to SMTP 
> host: localhost, port: 25 (_java.net.ConnectException_: Connection 
> refused: connect)
>
> at com.sun.mail.smtp.SMTPTransport.openServer(_SMTPTransport.java:867_)
>
> at 
> com.sun.mail.smtp.SMTPTransport.protocolConnect(_SMTPTransport.java:156_)
>
> at javax.mail.Service.connect(_Service.java:215_)
>
> at javax.mail.Service.connect(_Service.java:83_)
>
> at javax.mail.Service.connect(_Service.java:68_)
>
> at com.sun.mail.smtp.SMTPTransport.connect(_SMTPTransport.java:93_)
>
> at javax.mail.Transport.send(_Transport.java:92_)
>
> ... 5 more
>
> Caused by: _java.net.ConnectException_: Connection refused: connect
>
> at java.net.PlainSocketImpl.socketConnect(_Native Method_)
>
> at java.net.PlainSocketImpl.doConnect(Unknown Source)
>
> at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
>
> at java.net.PlainSocketImpl.connect(Unknown Source)
>
> at java.net.SocksSocketImpl.connect(Unknown Source)
>
> at java.net.Socket.connect(Unknown Source)
>
> at java.net.Socket.connect(Unknown Source)
>
> at java.net.Socket.<init>(Unknown Source)
>
> at java.net.Socket.<init>(Unknown Source)
>
> at com.sun.mail.util.SocketFetcher.getSocket0(_SocketFetcher.java:131_)
>
> at com.sun.mail.util.SocketFetcher.getSocket(_SocketFetcher.java:113_)
>
> at com.sun.mail.smtp.SMTPTransport.openServer(_SMTPTransport.java:836_)
>
> ... 11 more
>
> Thanks and Regards,
>
> Kamal
>
> **************** CAUTION - Disclaimer *****************
> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended 
> solely for the use of the addressee(s). If you are not the intended 
> recipient, please notify the sender by e-mail and delete the original 
> message. Further, you are not to copy, disclose, or distribute this 
> e-mail or its contents to any other person and any such actions are 
> unlawful. This e-mail may contain viruses. Infosys has taken every 
> reasonable precaution to minimize this risk, but is not liable for any 
> damage you may sustain as a result of any virus in this e-mail. You 
> should carry out your own virus checks before opening the e-mail or 
> attachment. Infosys reserves the right to monitor and review the 
> content of all messages sent to or from this e-mail address. Messages 
> sent to or from this e-mail address may be stored on the Infosys 
> e-mail system.
> ***INFOSYS******** End of Disclaimer ********INFOSYS***
>


Mime
View raw message