void sendMail() { SocketConnection sc = null; InputStream is = null; OutputStream os = null; //登录到邮件服务器 try { byte b[] = new byte[200]; int total = 0; sc = (SocketConnection) Connector.open("socket://" + servAdd + ":110"); is = sc.openInputStream(); os = sc.openOutputStream(); os.write( ("USER 该邮件地址已受到反垃圾邮件插件保护。要显示它需要在浏览器中启用 JavaScript。 ").getBytes()); total = is.read(b); response += new String(b, 0, total); os.write( ("PASS?123\r\n").getBytes()); total = is.read(b); response += new String(b, 0, total); //发送邮件 sc = (SocketConnection) Connector.open("socket://" + serverAdd + ":25"); is = sc.openInputStream(); os = sc.openOutputStream(); os.write( ("HELO there" + "\r\n").getBytes()); os.write( ("MAIL FROM: 该邮件地址已受到反垃圾邮件插件保护。要显示它需要在浏览器中启用 JavaScript。 ").getBytes()); os.write( ("RCPT TO: 该邮件地址已受到反垃圾邮件插件保护。要显示它需要在浏览器中启用 JavaScript。 ").getBytes()); os.write("DATA\r\n".getBytes()); os.write( ("From: 该邮件地址已受到反垃圾邮件插件保护。要显示它需要在浏览器中启用 JavaScript。 ").getBytes()); os.write( ("To: 该邮件地址已受到反垃圾邮件插件保护。要显示它需要在浏览器中启用 JavaScript。 ").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()); } catch (Exception e) {} }