【正文】
/** SMTP handshake. We need the name of the local machine. * Send the appropriate SMTP handshake mand. */ String localhost = 。 /** Read a line from server and check that the reply code is 220. If not, throw an IOException. */ String reply = ()。 fromServer = new BufferedReader(new InputStreamReader(()))。 /** Are we connected? Used in close() to determine what to do. */ private boolean isConnected = false。 private static final int SMTP_PORT = 25。 /** Streams for reading and writing the socket */ private BufferedReader fromServer。 import .*。 } } SMTPConnection import javax.*。 res += ()。 res += MXhost: + DestHost + , address: + DestAddr + \n。 } /** For printing the envelope. Only for debug. */ public String toString() { String res = Sender: + Sender + \n。 } = escapeBody。 if ((.)) { token = . + token。 StringTokenizer parser = new StringTokenizer(, \n, true)。 } private Message escapeMessage(Message message) { String escapeBody = 。 throw e。 } catch (UnknownHostException e) { (Unknown Host: + DestHost)。 /** Take the name of the local mailserver and map it into an I Address */ DestHost = localServer。 Recipient = ()。 /** The actual message. */ public Message Message。 /** Target MXhost */ public String DestHost。 public class Envelope { public String Sender。 import javax.*。 return res。 res = Headers + CRLF。 } return true。)) { (Recipient address is invalid.)。)) valid if (toat != (39。if (fromat 1 | ( fromat) 1) {validif (toat 1 | 1) {validif (fromat ! (39。39。 return false。39。 return false。 return false。)。 int toat = (39。39。 } public String getTo() { return To。 Body = text。 String dateString = (new Date())。GMT39。 Headers += Subject: + () + CRLF。 Headers = From: + From + CRLF。 /** Create the message object by inserting the required headers from RFC 822 (From, To, Date). */ public Message(String from, String to, String subject, String text) { /** Remove whitespace */ From = ()。 private String To。 public String Body。 import .*。 } } /* Quit */ class QuitListener implements ActionListener { public void actionPerformed(ActionEvent e) { (0)。 ()。 ()。 } (Mail send successfully!)。 } catch (IOException error) { (Sending failed: + error)。 (envelope)。 return。 try { envelope = new Envelope(mailMessage, ())。