Tianjin University Power Electronics Fan Zhongfang
Zffan@public.tpt.tj.cn
-------------------------------------------------- ------------------------------
To get feedback, I will be embedded on the home page when designing the home page. The most popular work in it is to use HTML words:
Feedback to author! This is the shortcomings that the reader uses Internet Explorer or Netscape Navigator. You need to open a write window when you click the author's address, so that the homepage window is covered. This reader does not easily take it in this reader. The author sets a Java applet on the home page to solve this problem, which makes people who do not have the Email address can also feed. The source program is as follows:
Import java.awt. *;
Import java.applet. *;
Import java.net. *;
Import java.io. *;
Public class javamail extends applet {
PRIVATE INT SMTP_PORT = 25;
// Mail server default port number
Private string appletsource = "202.99.96.140";
// Author Mail Server IP
PRIVATE TEXTAREA MSGAREA;
Private textfield senderfield, Recipientfield, Hostfield;
Public void init () {
SetLayout (New BorderLayout ());
Panel Fields = New Panel ();
Fields.setLayout (New GridLayout (3, 1));
Panel recpanel = new panel ();
Repnel.setLayout (New GridLayout (2, 1));
Repnel.Add (New Label ("Recipient"));
Recipientfield = New TextField ("zffan");
// Author's mail mail
Repnel.Add (RecipientField);
Fields.Add (Replanel);
Panel SendPanel = New Panel ();
SendPanel.setLayout (New GridLayout (2, 1));
Sendpanel.Add (New Label ("Sender"));
Senderfield = New TextField ("Your Name");
// Fill in the name of the user by the reader
Sendpanel.add (Senderfield);
Fields.Add (SendPanel);
Panel hostpanel = new panel ();
Hostpanel.setLayout (New GridLayout (2, 1));
Hostpanel.Add (New Label ("Host");
Hostfield = New TextField ("YourCompany.com");
// Fill in the mail server iphostpanel.add (Hostfield) by the reader;
Fields.Add (Hostpanel);
Add ("North", Fields);
Msgarea = new textarea ();
Add ("Center", Msgarea;
Add ("South", New Button ("Send");
}
Public Boolean Handleevent (Event E) {
IF (E.ID == Event.Window_Destroy)
System.exit (0);
Return super.handleevent (e);
}
Public Boolean Action (EVENT E, OBJECT ARG) {
IF (arg.equals ("send"))
SendMsg (Senderfield.getText (),
Recipientfield.getText (), Hostfield.getText ());
Else
Return Super.Action (E, ARG);
Return True;
}
Private Void Sendmsg (String Sender, String Recipient, String Senderhost) {
TRY {// Communication with the mail server
Socket S = New Socket (Appletsource, SMTP_PORT);
PRINTSTREAM OUT = New PrintStream (s.getoutputStream ());
Msgarea.selectall ();
Out.println ("Helo" Senderhost;
// The mail server does not authenticate if the reader is lost correctly.
Out.println ("Mail from:" Sender;
Out.println ("RCPT TO:" Recipient;
Out.println ("DATA");
Out.println (Msgarea.getSelectedText ());
OUT.PRINTLN (".");
Out.println ("quit");
}
Catch (Exception E) {System.out.println ("Error" E);}
}
} // javamail
The above is called at Win95, JDK1.1.2, and Hotjava Browser 1.0 ring. Interested readers can also add an error-free case when communicating with the SMTP server.