/* */ package NET.worlds.console; /* */ /* */ import java.io.IOException; /* */ import java.io.InputStream; /* */ import java.io.PrintWriter; /* */ import java.util.Enumeration; /* */ import java.util.Vector; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class MailMessage /* */ extends Thread /* */ { /* */ private String server; /* */ private String from; /* */ private String to; /* */ private Vector cc; /* */ private String subject; /* */ private Vector body; /* 43 */ private boolean lock = false; /* */ /* */ /* */ /* */ /* */ /* */ /* */ public MailMessage(String server) /* */ { /* 52 */ this(server, null, null, null, null); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public MailMessage(String server, String from, String to) /* */ { /* 66 */ this(server, from, to, null, null); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public MailMessage(String server, String from, String to, String subject, String body) /* */ { /* 85 */ this.server = server; /* 86 */ this.from = from; /* 87 */ this.to = to; /* 88 */ this.cc = new Vector(); /* 89 */ this.subject = subject; /* 90 */ this.body = new Vector(); /* 91 */ if (body != null) { /* 92 */ this.body.addElement(body); /* */ } /* */ } /* */ /* */ public void setFrom(String f) { /* 97 */ if (!locked()) { /* 98 */ this.from = f; /* */ } /* */ } /* */ /* */ public void setTo(String t) { /* 103 */ if (!locked()) { /* 104 */ this.to = t; /* */ } /* */ } /* */ /* */ public void addCC(String c) { /* 109 */ if (!locked()) { /* 110 */ this.cc.addElement(c); /* */ } /* */ } /* */ /* */ public void setSubject(String s) { /* 115 */ if (!locked()) { /* 116 */ this.subject = s; /* */ } /* */ } /* */ /* */ public void setBody(String b) { /* 121 */ if (!locked()) { /* 122 */ this.body = new Vector(); /* 123 */ this.body.addElement(b); /* */ } /* */ } /* */ /* */ public void appendBody(String b) /* */ { /* 129 */ if (!locked()) /* */ { /* */ /* */ /* 133 */ this.body.addElement(b); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void appendParagraphs(String text, String sepStr, int lineLen) /* */ { /* 154 */ if (!locked()) { /* 155 */ String b = ""; /* 156 */ String white = ""; /* 157 */ String word = ""; /* 158 */ boolean startParagraph = false; /* 159 */ int len = 0; /* */ /* 161 */ for (int i = 0; i < text.length(); i++) { /* 162 */ char c = text.charAt(i); /* */ /* */ /* 165 */ if ((word.length() > 0) && /* 166 */ (Character.isWhitespace(c))) { /* 167 */ len += white.length() + word.length(); /* 168 */ if (len > lineLen) { /* 169 */ b = b + sepStr; /* 170 */ len = word.length(); /* */ } else { /* 172 */ b = b + white; } /* 173 */ b = b + word; /* 174 */ word = ""; /* 175 */ white = ""; /* */ } /* */ /* */ /* */ /* 180 */ if ((c == '\n') || (c == '\r')) { /* 181 */ if (!startParagraph) { /* 182 */ len = 0; /* 183 */ b = b + sepStr; /* 184 */ b = b + sepStr; /* 185 */ startParagraph = true; /* */ } /* */ } else { /* 188 */ startParagraph = false; /* 189 */ if (Character.isWhitespace(c)) { /* 190 */ white = white + c; /* */ } else /* 192 */ word = word + c; /* */ } /* */ } /* 195 */ if (word.length() > 0) { /* 196 */ b = b + white; /* 197 */ b = b + word; /* */ } /* */ /* */ /* 201 */ this.body.addElement(b); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void appendParagraphs(String text) /* */ { /* 216 */ appendParagraphs(text, "\n", 70); /* */ } /* */ /* */ private synchronized void lockMessage() /* */ { /* 221 */ this.lock = true; /* */ } /* */ /* */ private synchronized void unlockMessage() /* */ { /* 226 */ this.lock = false; /* */ } /* */ /* */ private synchronized boolean locked() /* */ { /* 231 */ return this.lock; /* */ } /* */ /* */ /* */ /* */ protected void finished(boolean wasError) {} /* */ /* */ /* */ public void send() /* */ { /* 241 */ start(); /* */ } /* */ /* */ /* */ /* */ public void run() /* */ { /* 248 */ lockMessage(); /* 249 */ this.from = Console.parseUnicode(this.from); /* 250 */ this.to = Console.parseUnicode(this.to); /* 251 */ this.cc = Console.parseUnicode(this.cc); /* 252 */ this.subject = Console.parseUnicode(this.subject); /* 253 */ this.body = Console.parseUnicode(this.body); /* 254 */ boolean wasError = !sendNote(this.server, this.from, this.to, this.cc, this.subject, this.body); /* 255 */ unlockMessage(); /* 256 */ finished(wasError); /* */ } /* */ /* */ /* Error */ /* */ public static synchronized boolean sendNote(String server, String from, String to, Vector cc, String subject, Vector body) /* */ { /* */ // Byte code: /* */ // 0: bipush 25 /* */ // 2: istore 6 /* */ // 4: aload_0 /* */ // 5: bipush 58 /* */ // 7: invokevirtual 151 java/lang/String:indexOf (I)I /* */ // 10: istore 7 /* */ // 12: iload 7 /* */ // 14: iconst_m1 /* */ // 15: if_icmpeq +24 -> 39 /* */ // 18: aload_0 /* */ // 19: iload 7 /* */ // 21: iconst_1 /* */ // 22: iadd /* */ // 23: invokevirtual 155 java/lang/String:substring (I)Ljava/lang/String; /* */ // 26: invokestatic 159 java/lang/Integer:parseInt (Ljava/lang/String;)I /* */ // 29: istore 6 /* */ // 31: aload_0 /* */ // 32: iconst_0 /* */ // 33: iload 7 /* */ // 35: invokevirtual 165 java/lang/String:substring (II)Ljava/lang/String; /* */ // 38: astore_0 /* */ // 39: aconst_null /* */ // 40: astore 8 /* */ // 42: new 168 java/net/Socket /* */ // 45: dup /* */ // 46: aload_0 /* */ // 47: invokestatic 170 NET/worlds/network/DNSLookup:lookup (Ljava/lang/String;)Ljava/lang/String; /* */ // 50: iload 6 /* */ // 52: invokespecial 175 java/net/Socket: (Ljava/lang/String;I)V /* */ // 55: astore 8 /* */ // 57: aload 8 /* */ // 59: invokevirtual 178 java/net/Socket:getInputStream ()Ljava/io/InputStream; /* */ // 62: astore 9 /* */ // 64: new 182 java/io/PrintWriter /* */ // 67: dup /* */ // 68: aload 8 /* */ // 70: invokevirtual 184 java/net/Socket:getOutputStream ()Ljava/io/OutputStream; /* */ // 73: invokespecial 188 java/io/PrintWriter: (Ljava/io/OutputStream;)V /* */ // 76: astore 10 /* */ // 78: aload 9 /* */ // 80: invokestatic 191 NET/worlds/console/MailMessage:getReply (Ljava/io/InputStream;)Z /* */ // 83: ifeq +332 -> 415 /* */ // 86: aload 10 /* */ // 88: ldc -61 /* */ // 90: invokestatic 197 NET/worlds/console/MailMessage:print (Ljava/io/PrintWriter;Ljava/lang/String;)Z /* */ // 93: ifeq +322 -> 415 /* */ // 96: aload 9 /* */ // 98: invokestatic 191 NET/worlds/console/MailMessage:getReply (Ljava/io/InputStream;)Z /* */ // 101: ifeq +314 -> 415 /* */ // 104: aload 10 /* */ // 106: new 88 java/lang/StringBuilder /* */ // 109: dup /* */ // 110: ldc -55 /* */ // 112: invokespecial 94 java/lang/StringBuilder: (Ljava/lang/String;)V /* */ // 115: aload_1 /* */ // 116: invokevirtual 96 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder; /* */ // 119: ldc -53 /* */ // 121: invokevirtual 96 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder; /* */ // 124: invokevirtual 100 java/lang/StringBuilder:toString ()Ljava/lang/String; /* */ // 127: invokestatic 197 NET/worlds/console/MailMessage:print (Ljava/io/PrintWriter;Ljava/lang/String;)Z /* */ // 130: ifeq +285 -> 415 /* */ // 133: aload 9 /* */ // 135: invokestatic 191 NET/worlds/console/MailMessage:getReply (Ljava/io/InputStream;)Z /* */ // 138: ifeq +277 -> 415 /* */ // 141: aload 10 /* */ // 143: new 88 java/lang/StringBuilder /* */ // 146: dup /* */ // 147: ldc -51 /* */ // 149: invokespecial 94 java/lang/StringBuilder: (Ljava/lang/String;)V /* */ // 152: aload_2 /* */ // 153: invokevirtual 96 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder; /* */ // 156: ldc -53 /* */ // 158: invokevirtual 96 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder; /* */ // 161: invokevirtual 100 java/lang/StringBuilder:toString ()Ljava/lang/String; /* */ // 164: invokestatic 197 NET/worlds/console/MailMessage:print (Ljava/io/PrintWriter;Ljava/lang/String;)Z /* */ // 167: ifeq +248 -> 415 /* */ // 170: aload 9 /* */ // 172: invokestatic 191 NET/worlds/console/MailMessage:getReply (Ljava/io/InputStream;)Z /* */ // 175: ifeq +240 -> 415 /* */ // 178: aload 10 /* */ // 180: aload 9 /* */ // 182: aload_3 /* */ // 183: invokestatic 207 NET/worlds/console/MailMessage:printCCcmd (Ljava/io/PrintWriter;Ljava/io/InputStream;Ljava/util/Vector;)Z /* */ // 186: ifeq +229 -> 415 /* */ // 189: aload 10 /* */ // 191: ldc -45 /* */ // 193: invokestatic 197 NET/worlds/console/MailMessage:print (Ljava/io/PrintWriter;Ljava/lang/String;)Z /* */ // 196: ifeq +219 -> 415 /* */ // 199: aload 9 /* */ // 201: invokestatic 191 NET/worlds/console/MailMessage:getReply (Ljava/io/InputStream;)Z /* */ // 204: ifeq +211 -> 415 /* */ // 207: aload 10 /* */ // 209: ldc -43 /* */ // 211: invokestatic 197 NET/worlds/console/MailMessage:print (Ljava/io/PrintWriter;Ljava/lang/String;)Z /* */ // 214: ifeq +201 -> 415 /* */ // 217: aload 10 /* */ // 219: ldc -41 /* */ // 221: invokestatic 197 NET/worlds/console/MailMessage:print (Ljava/io/PrintWriter;Ljava/lang/String;)Z /* */ // 224: ifeq +191 -> 415 /* */ // 227: aload 10 /* */ // 229: new 88 java/lang/StringBuilder /* */ // 232: dup /* */ // 233: ldc -39 /* */ // 235: invokespecial 94 java/lang/StringBuilder: (Ljava/lang/String;)V /* */ // 238: aload_1 /* */ // 239: invokevirtual 96 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder; /* */ // 242: ldc -37 /* */ // 244: invokevirtual 96 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder; /* */ // 247: invokevirtual 100 java/lang/StringBuilder:toString ()Ljava/lang/String; /* */ // 250: invokestatic 197 NET/worlds/console/MailMessage:print (Ljava/io/PrintWriter;Ljava/lang/String;)Z /* */ // 253: ifeq +162 -> 415 /* */ // 256: aload 10 /* */ // 258: new 88 java/lang/StringBuilder /* */ // 261: dup /* */ // 262: ldc -35 /* */ // 264: invokespecial 94 java/lang/StringBuilder: (Ljava/lang/String;)V /* */ // 267: aload_2 /* */ // 268: invokevirtual 96 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder; /* */ // 271: ldc -37 /* */ // 273: invokevirtual 96 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder; /* */ // 276: invokevirtual 100 java/lang/StringBuilder:toString ()Ljava/lang/String; /* */ // 279: invokestatic 197 NET/worlds/console/MailMessage:print (Ljava/io/PrintWriter;Ljava/lang/String;)Z /* */ // 282: ifeq +133 -> 415 /* */ // 285: aload 10 /* */ // 287: aload_3 /* */ // 288: invokestatic 223 NET/worlds/console/MailMessage:printCCline (Ljava/io/PrintWriter;Ljava/util/Vector;)Z /* */ // 291: ifeq +124 -> 415 /* */ // 294: aload 10 /* */ // 296: new 88 java/lang/StringBuilder /* */ // 299: dup /* */ // 300: ldc -29 /* */ // 302: invokespecial 94 java/lang/StringBuilder: (Ljava/lang/String;)V /* */ // 305: aload 4 /* */ // 307: invokevirtual 96 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder; /* */ // 310: ldc -27 /* */ // 312: invokevirtual 96 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder; /* */ // 315: invokevirtual 100 java/lang/StringBuilder:toString ()Ljava/lang/String; /* */ // 318: invokestatic 197 NET/worlds/console/MailMessage:print (Ljava/io/PrintWriter;Ljava/lang/String;)Z /* */ // 321: ifeq +94 -> 415 /* */ // 324: aload 10 /* */ // 326: aload 5 /* */ // 328: invokestatic 231 NET/worlds/console/MailMessage:print (Ljava/io/PrintWriter;Ljava/util/Vector;)Z /* */ // 331: ifeq +84 -> 415 /* */ // 334: aload 10 /* */ // 336: ldc -23 /* */ // 338: invokestatic 197 NET/worlds/console/MailMessage:print (Ljava/io/PrintWriter;Ljava/lang/String;)Z /* */ // 341: ifeq +74 -> 415 /* */ // 344: aload 9 /* */ // 346: invokestatic 191 NET/worlds/console/MailMessage:getReply (Ljava/io/InputStream;)Z /* */ // 349: pop /* */ // 350: goto +65 -> 415 /* */ // 353: astore 9 /* */ // 355: getstatic 235 java/lang/System:out Ljava/io/PrintStream; /* */ // 358: new 88 java/lang/StringBuilder /* */ // 361: dup /* */ // 362: ldc -15 /* */ // 364: invokespecial 94 java/lang/StringBuilder: (Ljava/lang/String;)V /* */ // 367: aload 9 /* */ // 369: invokevirtual 243 java/lang/StringBuilder:append (Ljava/lang/Object;)Ljava/lang/StringBuilder; /* */ // 372: invokevirtual 100 java/lang/StringBuilder:toString ()Ljava/lang/String; /* */ // 375: invokevirtual 246 java/io/PrintStream:println (Ljava/lang/String;)V /* */ // 378: aload 8 /* */ // 380: ifnull +13 -> 393 /* */ // 383: aload 8 /* */ // 385: invokevirtual 251 java/net/Socket:close ()V /* */ // 388: goto +5 -> 393 /* */ // 391: astore 12 /* */ // 393: iconst_0 /* */ // 394: ireturn /* */ // 395: astore 11 /* */ // 397: aload 8 /* */ // 399: ifnull +13 -> 412 /* */ // 402: aload 8 /* */ // 404: invokevirtual 251 java/net/Socket:close ()V /* */ // 407: goto +5 -> 412 /* */ // 410: astore 12 /* */ // 412: aload 11 /* */ // 414: athrow /* */ // 415: aload 8 /* */ // 417: ifnull +13 -> 430 /* */ // 420: aload 8 /* */ // 422: invokevirtual 251 java/net/Socket:close ()V /* */ // 425: goto +5 -> 430 /* */ // 428: astore 12 /* */ // 430: getstatic 235 java/lang/System:out Ljava/io/PrintStream; /* */ // 433: ldc -2 /* */ // 435: invokevirtual 246 java/io/PrintStream:println (Ljava/lang/String;)V /* */ // 438: iconst_1 /* */ // 439: ireturn /* */ // Line number table: /* */ // Java source line #277 -> byte code offset #0 /* */ // Java source line #278 -> byte code offset #4 /* */ // Java source line #279 -> byte code offset #12 /* */ // Java source line #280 -> byte code offset #18 /* */ // Java source line #281 -> byte code offset #31 /* */ // Java source line #283 -> byte code offset #39 /* */ // Java source line #286 -> byte code offset #42 /* */ // Java source line #287 -> byte code offset #57 /* */ // Java source line #288 -> byte code offset #64 /* */ // Java source line #291 -> byte code offset #78 /* */ // Java source line #292 -> byte code offset #86 /* */ // Java source line #293 -> byte code offset #96 /* */ // Java source line #294 -> byte code offset #104 /* */ // Java source line #295 -> byte code offset #133 /* */ // Java source line #296 -> byte code offset #141 /* */ // Java source line #297 -> byte code offset #170 /* */ // Java source line #298 -> byte code offset #178 /* */ // Java source line #299 -> byte code offset #189 /* */ // Java source line #300 -> byte code offset #199 /* */ // Java source line #301 -> byte code offset #207 /* */ // Java source line #302 -> byte code offset #217 /* */ // Java source line #303 -> byte code offset #219 /* */ // Java source line #302 -> byte code offset #221 /* */ // Java source line #303 -> byte code offset #224 /* */ // Java source line #304 -> byte code offset #227 /* */ // Java source line #305 -> byte code offset #256 /* */ // Java source line #306 -> byte code offset #285 /* */ // Java source line #307 -> byte code offset #294 /* */ // Java source line #308 -> byte code offset #324 /* */ // Java source line #309 -> byte code offset #344 /* */ // Java source line #313 -> byte code offset #350 /* */ // Java source line #314 -> byte code offset #355 /* */ // Java source line #318 -> byte code offset #378 /* */ // Java source line #319 -> byte code offset #383 /* */ // Java source line #320 -> byte code offset #388 /* */ // Java source line #315 -> byte code offset #393 /* */ // Java source line #316 -> byte code offset #395 /* */ // Java source line #318 -> byte code offset #397 /* */ // Java source line #319 -> byte code offset #402 /* */ // Java source line #320 -> byte code offset #407 /* */ // Java source line #322 -> byte code offset #412 /* */ // Java source line #318 -> byte code offset #415 /* */ // Java source line #319 -> byte code offset #420 /* */ // Java source line #320 -> byte code offset #425 /* */ // Java source line #323 -> byte code offset #430 /* */ // Java source line #324 -> byte code offset #438 /* */ // Local variable table: /* */ // start length slot name signature /* */ // 0 440 0 server String /* */ // 0 440 1 from String /* */ // 0 440 2 to String /* */ // 0 440 3 cc Vector /* */ // 0 440 4 subject String /* */ // 0 440 5 body Vector /* */ // 2 49 6 port int /* */ // 10 24 7 cindex int /* */ // 40 381 8 smtpSocket java.net.Socket /* */ // 62 283 9 smtpIn InputStream /* */ // 353 15 9 ex IOException /* */ // 76 259 10 smtpOut PrintWriter /* */ // 395 18 11 localObject Object /* */ // 391 1 12 localIOException1 IOException /* */ // 410 1 12 localIOException2 IOException /* */ // 428 1 12 localIOException3 IOException /* */ // Exception table: /* */ // from to target type /* */ // 42 350 353 java/io/IOException /* */ // 378 388 391 java/io/IOException /* */ // 42 378 395 finally /* */ // 397 407 410 java/io/IOException /* */ // 415 425 428 java/io/IOException /* */ } /* */ /* */ private static boolean print(PrintWriter out, String text) /* */ { /* 329 */ out.print(text); /* 330 */ return !out.checkError(); /* */ } /* */ /* */ private static boolean print(PrintWriter out, Vector text) /* */ { /* 335 */ int size = text.size(); /* 336 */ for (int i = 0; i < size; i++) { /* 337 */ out.print((String)text.elementAt(i)); /* 338 */ if (out.checkError()) /* 339 */ return false; /* */ } /* 341 */ return true; /* */ } /* */ /* */ /* */ private static boolean printCCcmd(PrintWriter out, InputStream in, Vector cc) /* */ { /* 347 */ if (cc.size() > 0) { /* 348 */ Enumeration en = cc.elements(); /* 349 */ while (en.hasMoreElements()) { /* 350 */ String rcp = (String)en.nextElement(); /* 351 */ if (!print(out, "RCPT TO:<" + rcp + ">\r\n")) /* 352 */ return false; /* 353 */ if (!getReply(in)) /* 354 */ return false; /* */ } /* */ } /* 357 */ return true; /* */ } /* */ /* */ private static boolean printCCline(PrintWriter out, Vector cc) /* */ { /* 362 */ int num = cc.size(); /* 363 */ if (num > 0) { /* 364 */ if (!print(out, "cc: ")) /* 365 */ return false; /* 366 */ Enumeration en = cc.elements(); /* 367 */ while (en.hasMoreElements()) { /* 368 */ String rcp = (String)en.nextElement(); /* 369 */ if (num-- > 1) /* 370 */ rcp = rcp + ", "; /* 371 */ if (!print(out, rcp)) { /* 372 */ return false; /* */ } /* */ } /* 375 */ if (!print(out, "\r\n")) /* 376 */ return false; /* */ } /* 378 */ return true; /* */ } /* */ /* */ private static boolean getReply(InputStream in) /* */ { /* */ try { /* */ int result; /* */ do { /* 386 */ if ((result = in.read()) < 0) break; } while (result != 10); /* */ } /* */ catch (IOException ie) /* */ { /* 390 */ return false; /* */ } /* */ /* 393 */ return true; /* */ } /* */ /* */ /* */ /* */ public static void main(String[] args) /* */ { /* 400 */ Vector body = new Vector(); /* 401 */ body.addElement("Looks like it worked...\n"); /* */ /* */ /* 404 */ sendNote("www.3dcd.com:25", "Gamma Mail Service", /* 405 */ "thumper@alumni.caltech.edu", new Vector(), /* 406 */ "this is a test", body); /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\MailMessage.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */