You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Kamalanathan Raman <Ka...@infosys.com> on 2007/02/22 12:20:27 UTC

RE: javax.mail.MessagingException: .. could not connect to SMTPhost -Reg

Hi Rick,

   Thanks for replying, iam not sure from where it is picking the
"localhost" attribute . I have mentioned my mail server host which is
different everywhere in my application and also i have changed in the
"config.xml" file inside Geronimo/var folder also to reflect to my host
, but iam not sure from where it is picking up this attribute. Kindly
help me resolve this issue.

Thanks and Regards,
Kamal

-----Original Message-----
From: Rick McGuire [mailto:rickmcg@gmail.com] 
Sent: Thursday, February 22, 2007 3:50 PM
To: user@geronimo.apache.org
Subject: Re: javax.mail.MessagingException: .. could not connect to
SMTPhost -Reg

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***
>


RE: javax.mail.MessagingException: .. could not connect to SMTPhost-Reg

Posted by Kamalanathan Raman <Ka...@infosys.com>.
Hi Rick,

As u told I was having the sun mail.jar in my classpath , I removed it
and added the Geronimo-javamail-transport 1.1.1 jar to it, now it shows
this particular error . Is it something related to the firewall or is it
something that iam doing wrong with my application.


org.apache.geronimo.javamail.transport.smtp.SMTPSendFailedException:
5.7.3 Client does not have permission to submit mail to this server.
	at
org.apache.geronimo.javamail.transport.smtp.SMTPTransport.sendMessage(SM
TPTransport.java:479)
	at javax.mail.Transport.send(Transport.java:93)
	at javax.mail.Transport.send(Transport.java:46)
	at
com.symcor.common.util.SendMail.sendNotification(SendMail.java:172)
	at
com.symcor.common.util.SendMail.sendNotification(SendMail.java:93)
	at
com.symcor.eds.app.RunEDSService.sendMail(RunEDSService.java:411)
	at com.symcor.eds.app.RunEDSService.main(RunEDSService.java:338)
2007-02-22 18:12:35,841 INFO  com.symcor.common.util.SendMail
-sendNotification(...):exit
2007-02-22 18:12:35,841 ERROR root -main[]:5.7.3 Client does not have
permission to submit mail to this server.
org.apache.geronimo.javamail.transport.smtp.SMTPSendFailedException:
5.7.3 Client does not have permission to submit mail to this server.
	at
org.apache.geronimo.javamail.transport.smtp.SMTPTransport.sendMessage(SM
TPTransport.java:479)
	at javax.mail.Transport.send(Transport.java:93)
	at javax.mail.Transport.send(Transport.java:46)
	at
com.symcor.common.util.SendMail.sendNotification(SendMail.java:172)
	at
com.symcor.common.util.SendMail.sendNotification(SendMail.java:93)
	at
com.symcor.eds.app.RunEDSService.sendMail(RunEDSService.java:411)
	at com.symcor.eds.app.RunEDSService.main(RunEDSService.java:338)

Thanks and Regards,
Kamal

-----Original Message-----
From: Rick McGuire [mailto:rickmcg@gmail.com] 
Sent: Thursday, February 22, 2007 6:00 PM
To: user@geronimo.apache.org
Subject: Re: javax.mail.MessagingException: .. could not connect to
SMTPhost-Reg

Kamalanathan Raman wrote:
> Hi Rick,
>
> I forgot to mention one point in my previous mail , iam using the mail
> resource that is available in the Geronimo and see my
> geronimo-application.xml
>
> <gbean name="mail/MailSession"
> 		class="org.apache.geronimo.mail.MailGBean">
> 		<attribute name="transportProtocol">smtp</attribute>
> 		<attribute name="useDefault">false</attribute>
> 		<attribute
> name="host">BLRKECMSG13.ad.infosys.com</attribute>
> 		<attribute name="properties">
> 			mail.debug=true 
> 			mail.smtp.port=25
> 			mail.from=kamalanathan_raman@infosys.com
> 		</attribute>
> 	</gbean>
>   
If you are creating a Session using Sessiont.getInstance(), then you are

NOT using the mail resource.  If you're using javamail in that mode, 
than this configuration information has no effect on what happens. 

Rick


>
> Kindly let me know whether this is correct or do I need to change
> anything.
>
>
> Thanks and Regards,
> Kamal
>
> -----Original Message-----
> From: Rick McGuire [mailto:rickmcg@gmail.com] 
> Sent: Thursday, February 22, 2007 5:16 PM
> To: user@geronimo.apache.org
> Subject: Re: javax.mail.MessagingException: .. could not connect to
> SMTPhost-Reg
>
> I already did.  It is picking up the "localhost" attribute because
it's 
> not properly using the "mail.smtp.host" property to configure the
target
>
> SMTP host.  Either of the two solutions I gave you below will fix the 
> problem.
>
> How are you creating the mail Session in your application?  Are you 
> picking up the Geronimo mail resource, or are you configuring one 
> yourself by calling Session.getInstance() or 
> Session.getDefaultInstance()?  If you are using the Geronimo resource,

> then you need to specify a hostname on the MailGBean in your 
> config.xml.  The following added in the same section as the 
> SMTPTransport should do it:
>
>         <gbean name="mail/MailSession">
>             <attribute name="host">myhost</attribute>
>         </gbean>
>
> If you're not using the mail/MailResource provided by the server, then

> you need to make sure you set the property "mail.host" to your host in

> the property bundle you use when you call Session.getInstance(). 
>
> Rick
>
>
> Kamalanathan Raman wrote:
>   
>> Hi Rick,
>>
>>    Thanks for replying, iam not sure from where it is picking the
>> "localhost" attribute . I have mentioned my mail server host which is
>> different everywhere in my application and also i have changed in the
>> "config.xml" file inside Geronimo/var folder also to reflect to my
>>     
> host
>   
>> , but iam not sure from where it is picking up this attribute. Kindly
>> help me resolve this issue.
>>
>> Thanks and Regards,
>> Kamal
>>
>> -----Original Message-----
>> From: Rick McGuire [mailto:rickmcg@gmail.com] 
>> Sent: Thursday, February 22, 2007 3:50 PM
>> To: user@geronimo.apache.org
>> Subject: Re: javax.mail.MessagingException: .. could not connect to
>> SMTPhost -Reg
>>
>> 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***
>>>
>>>     
>>>       
>>   
>>     
>
>
>   


Re: javax.mail.MessagingException: .. could not connect to SMTPhost-Reg

Posted by Rick McGuire <ri...@gmail.com>.
Kamalanathan Raman wrote:
> Hi Rick,
>
> I forgot to mention one point in my previous mail , iam using the mail
> resource that is available in the Geronimo and see my
> geronimo-application.xml
>
> <gbean name="mail/MailSession"
> 		class="org.apache.geronimo.mail.MailGBean">
> 		<attribute name="transportProtocol">smtp</attribute>
> 		<attribute name="useDefault">false</attribute>
> 		<attribute
> name="host">BLRKECMSG13.ad.infosys.com</attribute>
> 		<attribute name="properties">
> 			mail.debug=true 
> 			mail.smtp.port=25
> 			mail.from=kamalanathan_raman@infosys.com
> 		</attribute>
> 	</gbean>
>   
If you are creating a Session using Sessiont.getInstance(), then you are 
NOT using the mail resource.  If you're using javamail in that mode, 
than this configuration information has no effect on what happens. 

Rick


>
> Kindly let me know whether this is correct or do I need to change
> anything.
>
>
> Thanks and Regards,
> Kamal
>
> -----Original Message-----
> From: Rick McGuire [mailto:rickmcg@gmail.com] 
> Sent: Thursday, February 22, 2007 5:16 PM
> To: user@geronimo.apache.org
> Subject: Re: javax.mail.MessagingException: .. could not connect to
> SMTPhost-Reg
>
> I already did.  It is picking up the "localhost" attribute because it's 
> not properly using the "mail.smtp.host" property to configure the target
>
> SMTP host.  Either of the two solutions I gave you below will fix the 
> problem.
>
> How are you creating the mail Session in your application?  Are you 
> picking up the Geronimo mail resource, or are you configuring one 
> yourself by calling Session.getInstance() or 
> Session.getDefaultInstance()?  If you are using the Geronimo resource, 
> then you need to specify a hostname on the MailGBean in your 
> config.xml.  The following added in the same section as the 
> SMTPTransport should do it:
>
>         <gbean name="mail/MailSession">
>             <attribute name="host">myhost</attribute>
>         </gbean>
>
> If you're not using the mail/MailResource provided by the server, then 
> you need to make sure you set the property "mail.host" to your host in 
> the property bundle you use when you call Session.getInstance(). 
>
> Rick
>
>
> Kamalanathan Raman wrote:
>   
>> Hi Rick,
>>
>>    Thanks for replying, iam not sure from where it is picking the
>> "localhost" attribute . I have mentioned my mail server host which is
>> different everywhere in my application and also i have changed in the
>> "config.xml" file inside Geronimo/var folder also to reflect to my
>>     
> host
>   
>> , but iam not sure from where it is picking up this attribute. Kindly
>> help me resolve this issue.
>>
>> Thanks and Regards,
>> Kamal
>>
>> -----Original Message-----
>> From: Rick McGuire [mailto:rickmcg@gmail.com] 
>> Sent: Thursday, February 22, 2007 3:50 PM
>> To: user@geronimo.apache.org
>> Subject: Re: javax.mail.MessagingException: .. could not connect to
>> SMTPhost -Reg
>>
>> 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***
>>>
>>>     
>>>       
>>   
>>     
>
>
>   


RE: javax.mail.MessagingException: .. could not connect to SMTPhost-Reg

Posted by Kamalanathan Raman <Ka...@infosys.com>.
Hi Rick,

I forgot to mention one point in my previous mail , iam using the mail
resource that is available in the Geronimo and see my
geronimo-application.xml

<gbean name="mail/MailSession"
		class="org.apache.geronimo.mail.MailGBean">
		<attribute name="transportProtocol">smtp</attribute>
		<attribute name="useDefault">false</attribute>
		<attribute
name="host">BLRKECMSG13.ad.infosys.com</attribute>
		<attribute name="properties">
			mail.debug=true 
			mail.smtp.port=25
			mail.from=kamalanathan_raman@infosys.com
		</attribute>
	</gbean>


Kindly let me know whether this is correct or do I need to change
anything.


Thanks and Regards,
Kamal

-----Original Message-----
From: Rick McGuire [mailto:rickmcg@gmail.com] 
Sent: Thursday, February 22, 2007 5:16 PM
To: user@geronimo.apache.org
Subject: Re: javax.mail.MessagingException: .. could not connect to
SMTPhost-Reg

I already did.  It is picking up the "localhost" attribute because it's 
not properly using the "mail.smtp.host" property to configure the target

SMTP host.  Either of the two solutions I gave you below will fix the 
problem.

How are you creating the mail Session in your application?  Are you 
picking up the Geronimo mail resource, or are you configuring one 
yourself by calling Session.getInstance() or 
Session.getDefaultInstance()?  If you are using the Geronimo resource, 
then you need to specify a hostname on the MailGBean in your 
config.xml.  The following added in the same section as the 
SMTPTransport should do it:

        <gbean name="mail/MailSession">
            <attribute name="host">myhost</attribute>
        </gbean>

If you're not using the mail/MailResource provided by the server, then 
you need to make sure you set the property "mail.host" to your host in 
the property bundle you use when you call Session.getInstance(). 

Rick


Kamalanathan Raman wrote:
> Hi Rick,
>
>    Thanks for replying, iam not sure from where it is picking the
> "localhost" attribute . I have mentioned my mail server host which is
> different everywhere in my application and also i have changed in the
> "config.xml" file inside Geronimo/var folder also to reflect to my
host
> , but iam not sure from where it is picking up this attribute. Kindly
> help me resolve this issue.
>
> Thanks and Regards,
> Kamal
>
> -----Original Message-----
> From: Rick McGuire [mailto:rickmcg@gmail.com] 
> Sent: Thursday, February 22, 2007 3:50 PM
> To: user@geronimo.apache.org
> Subject: Re: javax.mail.MessagingException: .. could not connect to
> SMTPhost -Reg
>
> 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***
>>
>>     
>
>
>   


RE: javax.mail.MessagingException: .. could not connect to SMTPhost-Reg

Posted by Kamalanathan Raman <Ka...@infosys.com>.
Hi Rick , 

The information u have given was really useful , now I have changed the
"mail.smtp.host" attribute to "mail.host" and now it is throwing this
particular error. As u said iam using the following code , by calling
"Session.getDefaultInstance" , find attached the code and the stack
trace that iam getting now. Kindly help me out. 

public static void sendNotification(String to, String from, String host,
String emailContent, String subject,
                                        String fileName) throws
MessagingException {
        final String methodName = "sendNotification(...)";
        try {
            if (logger.isEnabledFor(Priority.INFO)) {
                logger.log(Priority.INFO, new
LoggableMessage(methodName, true));
            }

            try {
                Properties props = System.getProperties();
                props.put("mail.host", host);

                Session session = Session.getDefaultInstance(props,
null);
                sendNotification(session, to, from, emailContent,
subject, fileName);
            } catch (MessagingException me) {
                logger.log(Priority.ERROR, new
LoggableMessage(methodName, "MessagingException "), me);
                throw me;
            }
        } finally {
            if (logger.isEnabledFor(Priority.INFO)) {
                logger.log(Priority.INFO, new
LoggableMessage(methodName, false));
            }
        }
    }


Stack trace :

javax.mail.SendFailedException: Send failure
(javax.mail.MessagingException: 454 5.7.3 Client does not have
permission to submit mail to this server.
)
	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:172)
	at
com.symcor.common.util.SendMail.sendNotification(SendMail.java:93)
	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: 454 5.7.3 Client does not have
permission to submit mail to this server.

	at
com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:879)
	at
com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:599)
	at
com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:319)
	at javax.mail.Transport.send(Transport.java:93)
	... 5 more
2007-02-22 17:22:50,066 INFO  com.symcor.common.util.SendMail
-sendNotification(...):exit
2007-02-22 17:22:50,066 ERROR root -main[]:Send failure
(javax.mail.MessagingException: 454 5.7.3 Client does not have
permission to submit mail to this server.
)
javax.mail.SendFailedException: Send failure
(javax.mail.MessagingException: 454 5.7.3 Client does not have
permission to submit mail to this server.
)
	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:172)
	at
com.symcor.common.util.SendMail.sendNotification(SendMail.java:93)
	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: 454 5.7.3 Client does not have
permission to submit mail to this server.

	at
com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:879)
	at
com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:599)
	at
com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:319)
	at javax.mail.Transport.send(Transport.java:93)
	... 5 more



Thanks and Regards,
Kamal
-----Original Message-----
From: Rick McGuire [mailto:rickmcg@gmail.com] 
Sent: Thursday, February 22, 2007 5:16 PM
To: user@geronimo.apache.org
Subject: Re: javax.mail.MessagingException: .. could not connect to
SMTPhost-Reg

I already did.  It is picking up the "localhost" attribute because it's 
not properly using the "mail.smtp.host" property to configure the target

SMTP host.  Either of the two solutions I gave you below will fix the 
problem.

How are you creating the mail Session in your application?  Are you 
picking up the Geronimo mail resource, or are you configuring one 
yourself by calling Session.getInstance() or 
Session.getDefaultInstance()?  If you are using the Geronimo resource, 
then you need to specify a hostname on the MailGBean in your 
config.xml.  The following added in the same section as the 
SMTPTransport should do it:

        <gbean name="mail/MailSession">
            <attribute name="host">myhost</attribute>
        </gbean>

If you're not using the mail/MailResource provided by the server, then 
you need to make sure you set the property "mail.host" to your host in 
the property bundle you use when you call Session.getInstance(). 

Rick


Kamalanathan Raman wrote:
> Hi Rick,
>
>    Thanks for replying, iam not sure from where it is picking the
> "localhost" attribute . I have mentioned my mail server host which is
> different everywhere in my application and also i have changed in the
> "config.xml" file inside Geronimo/var folder also to reflect to my
host
> , but iam not sure from where it is picking up this attribute. Kindly
> help me resolve this issue.
>
> Thanks and Regards,
> Kamal
>
> -----Original Message-----
> From: Rick McGuire [mailto:rickmcg@gmail.com] 
> Sent: Thursday, February 22, 2007 3:50 PM
> To: user@geronimo.apache.org
> Subject: Re: javax.mail.MessagingException: .. could not connect to
> SMTPhost -Reg
>
> 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***
>>
>>     
>
>
>   


Re: javax.mail.MessagingException: .. could not connect to SMTPhost -Reg

Posted by Rick McGuire <ri...@gmail.com>.
I already did.  It is picking up the "localhost" attribute because it's 
not properly using the "mail.smtp.host" property to configure the target 
SMTP host.  Either of the two solutions I gave you below will fix the 
problem.

How are you creating the mail Session in your application?  Are you 
picking up the Geronimo mail resource, or are you configuring one 
yourself by calling Session.getInstance() or 
Session.getDefaultInstance()?  If you are using the Geronimo resource, 
then you need to specify a hostname on the MailGBean in your 
config.xml.  The following added in the same section as the 
SMTPTransport should do it:

        <gbean name="mail/MailSession">
            <attribute name="host">myhost</attribute>
        </gbean>

If you're not using the mail/MailResource provided by the server, then 
you need to make sure you set the property "mail.host" to your host in 
the property bundle you use when you call Session.getInstance(). 

Rick


Kamalanathan Raman wrote:
> Hi Rick,
>
>    Thanks for replying, iam not sure from where it is picking the
> "localhost" attribute . I have mentioned my mail server host which is
> different everywhere in my application and also i have changed in the
> "config.xml" file inside Geronimo/var folder also to reflect to my host
> , but iam not sure from where it is picking up this attribute. Kindly
> help me resolve this issue.
>
> Thanks and Regards,
> Kamal
>
> -----Original Message-----
> From: Rick McGuire [mailto:rickmcg@gmail.com] 
> Sent: Thursday, February 22, 2007 3:50 PM
> To: user@geronimo.apache.org
> Subject: Re: javax.mail.MessagingException: .. could not connect to
> SMTPhost -Reg
>
> 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***
>>
>>     
>
>
>