0 Replies Latest reply: Mar 13, 2012 6:36 AM by 923487 RSS

    SMTP can only send RFC822 messages

    923487
      Getting MessagingException "SMTP can only send RFC822 messages" while sending EMails from Oracle DB 11.1.

      java stored procedure:

      CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "SendMail" as
      import java.util.Properties;
      import javax.mail.*;
      import javax.mail.internet.*;
      import javax.activation.*;
      import javax.mail.Session;
      import java.io.*;

      public class SendMail
      {

      public static String SendMessage( String recipient,String subject,String message,String from,
      String host, String user, String passwd )
      {
      try{
      Properties props = new Properties();
      props.setProperty("mail.transport.protocol", "smtp");
      props.setProperty("mail.host", host);
      props.setProperty("mail.user", user);
      props.setProperty("mail.password", passwd);
      props.setProperty("mail.smtp.auth","true");
      props.put("mail.debug", "true");

      Session session = Session.getDefaultInstance( props );
      session.setDebug(true);

      Transport transport = session.getTransport();

      MimeMessage msg = new MimeMessage( session );

      InternetAddress addressFrom = new InternetAddress( from );
      msg.setFrom( addressFrom );
      InternetAddress addressTo = new InternetAddress( recipient );
      msg.setRecipient( Message.RecipientType.TO, addressTo );

      msg.setSubject( subject );
      msg.setText( message);

      transport.connect(host, user, passwd);
      transport.sendMessage(msg,msg.getAllRecipients());
      transport.close();

      return("sent!");
      } catch (Exception es){  
      es.printStackTrace();
      return(es.getMessage());
      }
      }
      }
      /

      There is no Exception when i compile and use this with the same JDK outsite the DB.