0 Replies Latest reply on Apr 30, 2004 4:24 PM by oren.gross

    Simple JavaMail program fails


      Hi there, I am using Jboss 3.2.3 and I ahve a simple JavaMail program that runs perfectly on a standalone system (non-J2EE) but fails while running in Jboss...

      public void postMail(String recipient, String subject, String message, String from) throws MessagingException, UnsupportedEncodingException {
       boolean debug = true;
       Properties props = new Properties();
       props.put("mail.smtp.host", smtpHost);
       props.put("mail.smtp.auth", "true");
       Session session = Session.getDefaultInstance(props);
       Transport trans = session.getTransport("smtp");
       trans.connect(null, name, password);
       Address toAddr[] = {new InternetAddress(from)};
       Address fromAddr[] =
       fromAddr = new Address[]{new InternetAddress(from, "My Name")};
       Message msg = new MimeMessage(session);
       msg.setRecipient(Message.RecipientType.TO, toAddr[0]);
       msg.setContent("This is a test - you can safely ignore this message", "text/plain");
       trans.sendMessage(msg, toAddr);
       public static void main(String args[]) throws Exception {
       String from = args[0];
       String to = args[1];
       MailExample mailExample = new MailExample();
       mailExample.postMail("ogross74@yahoo.com","test subject", "a message","ogross74@yahoo.com");

      While sucessfuly sending Email on a stand-alone system, running from my webapplication I get:

      javax.mail.MessagingException: 530 MAIL requires AUTH
       at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:923)
       at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:643)
       at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:322)
       at com.snap.email.MailExample.postMail(MailExample.java:47)

      Any ideas?