Repository: mercurial
Revision: 97
Author: Bill Shannon <bill.shannon_at_sun.com>
Date: 2008-12-09 23:00:17 UTC
Log Message:
-----------
Add some comments.
Modified Paths:
--------------
demo/src/main/java/msgsend.java
demo/src/main/java/smtpsend.java
Diffs:
-----
diff -r 63ebf52122e9 -r d189c67ccf11 demo/src/main/java/msgsend.java
--- a/demo/src/main/java/msgsend.java Tue Dec 09 14:52:52 2008 -0800
+++ b/demo/src/main/java/msgsend.java Tue Dec 09 15:00:17 2008 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -62,6 +62,9 @@
new BufferedReader(new
InputStreamReader(System.in));
int optind;
+ /*
+ * Process command line arguments.
+ */
for (optind = 0; optind < argv.length; optind++) {
if (argv[optind].equals("-T")) {
protocol = argv[++optind];
@@ -106,6 +109,9 @@
}
try {
+ /*
+ * Prompt for To and Subject, if not specified.
+ */
if (optind < argv.length) {
// XXX - concatenate all remaining arguments
to = argv[optind];
@@ -123,6 +129,9 @@
System.out.println("Subject: " + subject);
}
+ /*
+ * Initialize the JavaMail Session.
+ */
Properties props = System.getProperties();
// XXX - could use Session.getTransport() and
Transport.connect()
// XXX - assume we're using SMTP
@@ -134,7 +143,9 @@
if (debug)
session.setDebug(true);
- // construct the message
+ /*
+ * Construct the message and send it.
+ */
Message msg = new MimeMessage(session);
if (from != null)
msg.setFrom(new InternetAddress(from));
@@ -179,8 +190,9 @@
System.out.println("\nMail was sent successfully.");
- // Keep a copy, if requested.
-
+ /*
+ * Save a copy of the message, if requested.
+ */
if (record != null) {
// Get a Store object
Store store = null;
@@ -222,6 +234,9 @@
}
}
+ /**
+ * Read the body of the message until EOF.
+ */
public static String collect(BufferedReader in) throws IOException
{
String line;
StringBuffer sb = new StringBuffer();
diff -r 63ebf52122e9 -r d189c67ccf11 demo/src/main/java/smtpsend.java
--- a/demo/src/main/java/smtpsend.java Tue Dec 09 14:52:52 2008 -0800
+++ b/demo/src/main/java/smtpsend.java Tue Dec 09 15:00:17 2008 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -91,6 +91,9 @@
new BufferedReader(new
InputStreamReader(System.in));
int optind;
+ /*
+ * Process command line arguments.
+ */
for (optind = 0; optind < argv.length; optind++) {
if (argv[optind].equals("-T")) {
protocol = argv[++optind];
@@ -143,6 +146,9 @@
}
try {
+ /*
+ * Prompt for To and Subject, if not specified.
+ */
if (optind < argv.length) {
// XXX - concatenate all remaining arguments
to = argv[optind];
@@ -160,6 +166,9 @@
System.out.println("Subject: " + subject);
}
+ /*
+ * Initialize the JavaMail Session.
+ */
Properties props = System.getProperties();
if (mailhost != null)
props.put("mail." + prot + ".host", mailhost);
@@ -186,7 +195,9 @@
session.addProvider(p);
*/
- // construct the message
+ /*
+ * Construct the message and send it.
+ */
Message msg = new MimeMessage(session);
if (from != null)
msg.setFrom(new InternetAddress(from));
@@ -253,8 +264,9 @@
System.out.println("\nMail was sent successfully.");
- // Keep a copy, if requested.
-
+ /*
+ * Save a copy of the message, if requested.
+ */
if (record != null) {
// Get a Store object
Store store = null;
@@ -292,6 +304,9 @@
}
} catch (Exception e) {
+ /*
+ * Handle SMTP-specific exceptions.
+ */
if (e instanceof SendFailedException) {
MessagingException sfe = (MessagingException)e;
if (sfe instanceof SMTPSendFailedException) {
@@ -341,6 +356,9 @@
}
}
+ /**
+ * Read the body of the message until EOF.
+ */
public static String collect(BufferedReader in) throws IOException
{
String line;
StringBuffer sb = new StringBuffer();