日期:2014-05-20  浏览次数:20902 次

J2ME 实现简单电子邮件发送功能 有关验证问题!!!!!
本地测试通过,不能向外发邮件,请教有关验证问题?有人可以告诉我如何加入验证代码吗   ?如何写?
---MIDlet---
package   com;
import   java.io.DataOutputStream;
import   java.io.IOException;
import   javax.microedition.midlet.MIDlet;
import   javax.microedition.midlet.MIDletStateChangeException;
import   javax.microedition.lcdui.*;
import   javax.microedition.io.*;
public   class   MailClient   extends   MIDlet
{
private   MainForm   mainForm;
private   ContentForm   contentForm;
private   Display   display;
private   Message   message;
public   Message   getMessage()
{
return   message;
}
public   void   setMessage(Message   message)
{
this.message   =   message;
}
public   void   displayAlert(String   text,   AlertType   type,   Displayable   disp)
{
Alert   alert   =   new   Alert( "Application   Error ");
alert.setString(text);
alert.setType(type);
alert.setTimeout(2000);
display.setCurrent(alert,   disp);
}
public   ContentForm   getContentForm()
{
return   contentForm;
}
public   Display   getDisplay()
{
return   display;
}
public   MainForm   getMainForm()
{
return   mainForm;
}
public   void   initMIDlet()
{
MailThread   t   =   new   MailThread(this);
t.start();
message   =   new   Message();
display   =   Display.getDisplay(this);
mainForm   =   new   MainForm(this,   "Simple   Mail   Client ");
contentForm   =   new   ContentForm( "Content ",   null,   150,   TextField.ANY,   this);
display.setCurrent(mainForm);
}
protected   void   startApp()   throws   MIDletStateChangeException
{
initMIDlet();
}
protected   void   pauseApp()
{
}
protected   void   destroyApp(boolean   arg0)   throws   MIDletStateChangeException
{
}
}
class   MailThread   extends   Thread
{
private   MailClient   midlet;
public   MailThread(MailClient   midlet)
{
this.midlet   =   midlet;
}
public   void   run()
{
synchronized(midlet)
{
try
{
midlet.wait();
}
catch(Exception   e)
{
e.printStackTrace();
}
}
System.out.println( "connecting   to   server..... ");
HttpConnection   httpConn   =   null;
DataOutputStream   dos   =   null;
try
{
httpConn   =
(HttpConnection)Connector.open( "http://localhost:8888/Maile/MaileServlet ");
httpConn.setRequestMethod( "POST ");
dos   =   new   DataOutputStream(httpConn.openOutputStream());
dos.writeUTF(midlet.getMessage().getTo());
dos.writeUTF(midlet.getMessage().getSubject());
dos.writeUTF(midlet.getMessage().getContent());
dos.close();
httpConn.close();
System.out.println( "end   of   sending   mail ");
}
catch(IOException   e)
{}
}
}
-----------servlet--------------

package   com;
import   java.io.DataInputStream;
import   java.io.IOException;
import   java.util.Properties;
import   javax.servlet.ServletConfig;
import   javax.servlet.ServletException;