Skip to main content

Configuring Java Mail Session

3 replies [Last post]
duke_nuke
Offline
Joined: 2010-02-01
Points: 0

I have configured a mail session in glassfish v3 with Mail Host to my SMTP server
but i run my page that sends an email that throws the following exception
javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
nested exception is:
java.net.ConnectException: Connection refused: connect
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1706)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:525)
at javax.mail.Service.connect(Service.java:291)
at javax.mail.Service.connect(Service.java:172)

it looks that its finding smtp server locally not that which i have provided when configuring
mail session any help would be appriciated
thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Felipe Gaucho

Please bring us your CLI or a screenshot of your config details...

On 11.02.2010, at 17:05, webtier@javadesktop.org wrote:

> I have configured a mail session in glassfish v3 with Mail Host to
> my SMTP server
> but i run my page that sends an email that throws the following
> exception
> javax.mail.MessagingException: Could not connect to SMTP host:
> localhost, port: 25;
> nested exception is:
> java.net.ConnectException: Connection refused: connect
> at com.sun.mail.smtp.SMTPTransport.openServer
> (SMTPTransport.java:1706)
> at com.sun.mail.smtp.SMTPTransport.protocolConnect
> (SMTPTransport.java:525)
> at javax.mail.Service.connect(Service.java:291)
> at javax.mail.Service.connect(Service.java:172)
>
> it looks that its finding smtp server locally not that which i have
> provided when configuring
> mail session any help would be appriciated
> thanks
> [Message sent by forum member 'duke_nuke' (khurram_noor@msn.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=386150
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

duke_nuke
Offline
Joined: 2010-02-01
Points: 0

How can i show you the attachment , there is no option here for the attachments

here are the values

JNDI Name : mailServer
Mail Host : mail.simas2.ch
Default User : mailHostUser
Status : enabled

Advanced

Store Protocol : imap
Store Protocol Class : com.sun.mail.imap.IMAPStore
Transport Protocol : smtp
Transport Protocol Class : com.sun.mail.smtp.SMTPTransport

and i have added an additional property
mail-password : tomypassword

hope you got idea from these config
thanks

Felipe Gaúcho

you can use command line to configure such resources...

here you find examples of scripts to configure Glassfish resources:
http://kenai.com/projects/puj/sources/arena/show/arena-puj?rev=445

For example, you can configure a GMail SMTP typing the following
command in a console:

asadmin --interactive=false create-javamail-resource
--mailhost=$MAIL_HOST --mailuser=$MAIL_USER --fromaddress=$MAIL_FROM
--enabled=true --description="e-Mail account used to confirm the
registration of the Arena PUJ users" --storeprotocol=imap
--storeprotocolclass=com.sun.mail.imap.IMAPStore --transprotocol smtp
--transprotocolclass com.sun.mail.smtp.SMTPSSLTransport --property
mail-smtp.user=$MAIL_SMTP_USER:mail-smtp.port=465:mail-smtp.password=$MAIL_SMTP_PASSWORD:mail-smtp.auth=true:mail-smtp.socketFactory.fallback=false:mail-smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory:mail-smtp.socketFactory.port=$MAIL_SMTP_PORT:mail-smtp.starttls.enable=true
mail/arena

Glassfish official info here:
http://docs.sun.com/app/docs/doc/820-7701/create-javamail-resource-1?a=view

* you should be able to configure all these parameters in the
Graphical interface as well, it is a matter of personal preference ..
but sometimes I loose more time looking for buttons and forms than
trigger that through line commands.. :)

On Fri, Feb 12, 2010 at 4:34 AM, wrote:
> How can i show you the attachment , there is no option here for the attachments
>
> here are the values
>
> JNDI Name : mailServer
> Mail Host : mail.simas2.ch
> Default User : mailHostUser
> Status : enabled
>
> Advanced
>
> Store Protocol : imap
> Store Protocol Class : com.sun.mail.imap.IMAPStore
> Transport Protocol : smtp
> Transport Protocol Class : com.sun.mail.smtp.SMTPTransport
>
> and i have added an additional property
> mail-password : tomypassword
>
>
> hope you got idea from these config
> thanks
> [Message sent by forum member 'duke_nuke' (khurram_noor@msn.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=386283
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>

--
------------------------------------------
Felipe Gaúcho
10+ Java Programmer
CEJUG Senior Advisor

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net