• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

problem in mail sending

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello friends i am using glashfish application server.i have already configured java mail session there & injecting that resource into java application.I want to send mail with attatchment .but i can't be able to send mail .so can you please check it out what was the issue in the code that has been triggered out .i am trying hard but cant able to solve query:

suppose i am configuring java mail session that is required to give name of jndi prefix to mail such as mail/MySession.can it be same applied to jms,jdbc resources,i am getting confused in that as well..

i am pasting out code here:

i have already set following properties into glashfish server:
JNDI Name:MyMailConfig

Mail Host: smtp.gmail.com

Default User :JAVA Geek

Default Sender Address:********@gmail.com

Deployement Order :100

Advance properties :
Store Protocol: imap

Store Protocol Class: com.sun.mail.imap.IMAPStore

Transport Protocol:smtp

Transport Protocol Class:com.sun.mail.smtp.SMTPTransport

Additional Properties which are defined as follows:

mail.smtp.socketFactory.class :javax.net.ssl.SSLSocketFactory

mail.smtp.password :*********

mail.smtp.auth:true

mail.smtp.socketFactory.fallback: false

mail.smtp.socketFactory.port:465

The Client code which i have written as follows:





when i run this application i didnt found anything on console.so need help


can you please help me out guys..
thanks in advance.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

when i run this application i didnt found anything on console.so need help



Of course not, because of this:

Don't ever do this, at least print something to where you will see it. But even then it's not going to work - I see no code that would deal with authentication, which is mandatory for sending email these days, certainly when using Gmail.
 
nisu pathak
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey i have edited the code & i am getting this error:


Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:344)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.main.Main.runTest(Main.java:22)
at org.main.Main.main(Main.java:58)
reply
    Bookmark Topic Watch Topic
  • New Topic