2 Replies Latest reply on Oct 5, 2006 11:25 AM by James Rhodes

    Javamail hell with 4.04GA

    James Rhodes Newbie

      Has anyone gotten javamail to work?? I get ClassNotFoundExceptions when I uses mime/multipart messages and I get SendFailedExceptions "can only send RFC822 compliant messages" when I just use something like the following code:
      Session mailSession = null;
      try {
      Context ctx = new InitialContext();
      //Context compEnv = (Context) ctx.lookup("java:comp/env");
      //mailSession = (Session)compEnv.lookup("mail/AppMail");
      Object objref = ctx.lookup("java:comp/env/mail/AppMail");
      mailSession = (Session) PortableRemoteObject.narrow(objref, Session.class);
      } catch (NamingException e) {
      // TODO Auto-generated catch block
      System.out.println(e);
      e.printStackTrace();
      }

      InternetAddress[] address = new InternetAddress[to.length];
      for(int i = 0; i < to.length; i++)
      {
      address = new InternetAddress(to);
      }

      // Define message
      MimeMessage message = new MimeMessage(mailSession);
      message.setFrom(new InternetAddress(from));
      message.addRecipients(Message.RecipientType.TO,address);
      message.setSubject("Hello JavaMail");
      message.setText("Welcome to JavaMail");
      //I've tried it without this too
      message.setHeader("Date",new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z").format(new Date(System.currentTimeMillis())));

      // Send message
      Transport.send(message);

      Someone please enlighten me. I've even tried the new version of javamail with no luck.

      B

        • 1. Re: Javamail hell with 4.04GA
          James Rhodes Newbie

          Here is the debug output I'm seeing:

          250-STARTTLS
          250-8BITMIME
          250-DSN
          250 OVID
          11:17:23,785 INFO [STDOUT] DEBUG SMTP: Found extension "STARTTLS", arg ""
          11:17:23,785 INFO [STDOUT] DEBUG SMTP: Found extension "8BITMIME", arg ""
          11:17:23,785 INFO [STDOUT] DEBUG SMTP: Found extension "DSN", arg ""
          11:17:23,800 INFO [STDOUT] DEBUG SMTP: Found extension "OVID", arg ""
          11:17:23,800 INFO [STDOUT] DEBUG SMTP: Can only send RFC822 msgs
          11:17:23,800 INFO [STDOUT] QUIT

          • 2. Re: Javamail hell with 4.04GA
            James Rhodes Newbie

            Here is my exception:
            MessagingException:
            SMTP can only send RFC822 messages

            Also, I've tried sending through both windows and linux mail servers with the same luck.