0

hi all i have been trying to write the a j2me email client code which enables the midlet to send an email into my account but i faced the following error "Must issue a STARTTLS Command first" here is the code and i included the result shown on emulator with the image and i got the starting source code from [oracle java me website][1]

       
      
 
      try {
    //smtpServerAddress=smtp.gmail.com
         sc = (SocketConnection)Connector.open("socket://"+smtpServerAddress+":587");
         is = sc.openInputStream();
         os = sc.openOutputStream();

         os.write(("HELO there" + "\r\n").getBytes()); 
         os.write(("MAIL FROM: "+ from +"\r\n").getBytes());
         os.write(("RCPT TO: "+ to + "\r\n").getBytes());
         os.write("DATA\r\n".getBytes());
         
         os.write(("From: "+from+"\r\n").getBytes());
         os.write(("To: "+to+"\r\n").getBytes());
         os.write(("Subject: "+subject+"\r\n").getBytes());
         os.write((msg+"\r\n").getBytes()); // message body
         os.write(".\r\n".getBytes());
         os.write("QUIT\r\n".getBytes());

         // debug
         StringBuffer sb = new StringBuffer();
         int c = 0;
         while (((c = is.read()) != -1) ) {
            sb.append((char) c);
         }
         si.setText("SMTP server response - " + sb.toString());      

      } catch(IOException e) {}```



[the image shows the output result on emulator][2]


  [1]: https://www.oracle.com/technical-resources/articles/javame/lowlevel-networkprogramming-midp20.html
  [2]: https://i.sstatic.net/YJ0Y0.png
3
  • The server is asking you to use TLS. Also what a blast from the past, I haven't seen that MIDlet emulator in over 15 years or something. Commented Dec 17, 2021 at 9:10
  • You'd need to use an SMTP server that doesn't require SSL. Google doesn't allow that for security reasons. Commented Dec 17, 2021 at 9:18
  • You could add a J2ME TLS library to your app. Your current code is acting like a telnet. stackoverflow.com/questions/32663768/… Commented Dec 20, 2021 at 11:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.