tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Peremsky <mperem...@yahoo.com>
Subject Noob trying to figure out JavaMail
Date Tue, 03 Jul 2007 14:25:08 GMT
I am trying send emails in the app I am creating.I know from the examples that I can use 
   
  Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
Session session = (Session) envCtx.lookup("mail/Session");
  Message msg = new MimeMessage(session)
  msg.addRecipients(recp);
  msg.addFrom(from);
  msg.setContent(messageText, "text/plain");
  Transport.send(msg)

  However, I would prefer to set up the MailSession by passing in a properties list to the
similar to:
   
  Session mailSession = Session.getInstance(mailProperties, null);
  Message msg = new MimeMessage(session)
  msg.addRecipients(recp);
  msg.addFrom(from);
  msg.setContent(messageText, "text/plain");
  Transport.send(msg)

   
  mailhost is defined in my host file as: 10.1.1.120
   
  I also have the following defined in my web.xml:
   
  <resource-ref>
      <res-ref-name>mail/Session</res-ref-name>
      <res-type>java.xmail.Session</res-type>
     <res-auth>Container</res-auth>
     <res-sharing-scope>Shareable</res-sharing-scope>
  </resource-ref>
  
I am not sure what is missing from my machine. I have set my host, timout and debug flags.
When I try to send the email I now get the message: java.net.NoRouteToHostException.
   
  Is thi smessage coming because I am currently not hooked up to a network? Do I need to set
up something else on my server? Do I need network connectivity?
   
  TIA
   
  - Mike

       
---------------------------------
Be a better Heartthrob. Get better relationship answers from someone who knows.
Yahoo! Answers - Check it out. 
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message