[jboss-user] [Beginners Corner] - javamail help: does it work with 4.04.ga?

bezdomny do-not-reply at jboss.com
Thu Oct 5 11:29:04 EDT 2006


Has anyone gotten javamail to work?? I get ClassNotFoundExceptions when I uses mime/multipart messages and I get MessagingExceptions "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"); 
// Send message 
Transport.send(message); 
 
 
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 
 
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.  

Thanks!

B 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976333#3976333

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976333



More information about the jboss-user mailing list