(thread = new Thread(this)).start();
JEditTextArea textArea = view.getTextArea();  String smtp = this.smtp.getText(); String from = this.from.getText(); String to = this.to.getText(); String subject = this.subject.getText(); boolean selectionOnly = this.selectionOnly.isSelected();  if(smtp.length() == 0 || from.length() == 0 || to.length() == 0) { error("sendempty"); return; }  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));  Object[] args = { smtp }; Log.log(Log.DEBUG,this,jEdit.getProperty("send.connect",args));  try { int index = smtp.indexOf(':'); int port = 25; if(index != -1) { port = Integer.parseInt(smtp.substring(index + 1)); smtp = smtp.substring(0,index); }  Socket socket = new Socket(smtp,port); BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); Writer out = new OutputStreamWriter(socket .getOutputStream());  String response = in.readLine(); Log.log(Log.DEBUG,this,response); if(!response.startsWith("220")) { error("serverdown"); return; }  String command = "HELO " + socket.getLocalAddress() .getHostName() + CRLF; Log.log(Log.DEBUG,this,command); out.write(command); out.flush();  response = in.readLine(); Log.log(Log.DEBUG,this,response); if(!response.startsWith("250")) { error("badhost"); return; } command = "MAIL FROM: <" + from + ">" + CRLF; Log.log(Log.DEBUG,this,command); out.write(command); out.flush();  response = in.readLine(); Log.log(Log.DEBUG,this,response); if(!response.startsWith("250")) { error("badsender"); return; } command = "RCPT TO: <" + to + ">" + CRLF; Log.log(Log.DEBUG,this,command); out.write(command); out.flush();  response = in.readLine(); Log.log(Log.DEBUG,this,response); if(!response.startsWith("250")) { error("badrecepient"); return; } command = "DATA" + CRLF; Log.log(Log.DEBUG,this,command); out.write(command); out.flush();  response = in.readLine(); Log.log(Log.DEBUG,this,response); if(!response.startsWith("354")) { error("badmsg"); return; }  out.write("Subject: " + subject); out.write(CRLF); out.write("X-Mailer: jEdit " + jEdit.getVersion()); out.write(CRLF); out.write(CRLF);  Buffer buffer = view.getBuffer();  int startLine, endLine; if(selectionOnly) { startLine = textArea.getSelectionStartLine(); endLine = textArea.getSelectionEndLine(); } else { startLine = 0; endLine = textArea.getLineCount() - 1; }  for(int i = startLine; i <= endLine; i++) { String line;  if(selectionOnly) { int start = textArea.getSelectionStart(i); int end = textArea.getSelectionEnd(i);  line = textArea.getText(start,end - start); } else { line = textArea.getLineText(i); }  if(line.equals(".")) line = "!"; out.write(line); out.write(CRLF); }  out.write("." + CRLF); out.flush();  response = in.readLine(); Log.log(Log.DEBUG,this,response); if(!response.startsWith("250")) { error("badmsg"); return; } command = "QUIT" + CRLF; Log.log(Log.DEBUG,this,command); out.write(command); out.flush();  response = in.readLine(); Log.log(Log.DEBUG,this,response); in.close(); out.close(); socket.close();  save(); dispose(); } catch(IOException io) { Log.log(Log.ERROR,this,io); args[0] = io.toString(); GUIUtilities.error(view,"ioerror",args); } catch(NumberFormatException nf) { Log.log(Log.ERROR,this,nf); GUIUtilities.error(view,"badport",null); }  setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
	public void ok()	{		(thread = new Thread(this)).start();	}