0N/A README for the demo programs in this directory
0N/A ==============================================
0N/A
0N/AThese demo programs illustrate how to use the JavaMail API to
0N/Aperform a number of common email functions. Note these these
0N/Aprograms are not intended to be examples of good user interfaces,
0N/Aor good command line interfaces. No one is expected to actually
0N/A*use* these programs for anything real. Rather, their value is
0N/Ain the source code. Don't look at their command line arguments
0N/Aor user interface to figure out what JavaMail can do, look at
0N/Atheir source code. We strongly recommend that you read the
0N/Asource code and understand what these programs are doing before
0N/Arunning them.
0N/A
0N/AAll of these programs are simple command line tools with a UNIX
0N/Astyle interface. On Windows you'll need to run them in an MS-DOS
0N/Awindow. We apologize in advance for the inconsistency in how these
0N/Aprograms accept options. There are generally two styles. The very
0N/Asimple style (e.g., as used by copier.java) requires a fixed number
0N/Aof arguments in a fixed order. Others (e.g., folderlist.java) take
0N/AUNIX-style options, many of which are optional, and which may appear
0N/Ain any order. The following notes should help you figure it out,
0N/Abut if in doubt, read the source code.
0N/A
0N/A
0N/A
0N/A- copier.java
0N/A
0N/A This program copies the specified messages from one folder to
0N/A another. Both folders must belong to the same store.
0N/A
0N/A Usage:
0N/A java copier <urlname> <src> <dest> <start> <end>
0N/A
0N/A Arguments (in order):
0N/A
0N/A <urlname> : URL of the Store. The URL should include
0N/A the password as well (if needed).
0N/A Example: "imap://john:password@mailstore.com"
0N/A
0N/A <src> : source folder
0N/A <dest> : destination folder
0N/A <start> : start message number
0N/A <end> : end message number
0N/A
0N/A
0N/A- folderlist.java
0N/A
0N/A This program lists information about the folders in a Store.
0N/A
0N/A Usage:
0N/A java folderlist -L <url> -T <protocol> -H <host> -U <user> -P <passwd>
0N/A [-R <root>] [-r] [-v] [-D] <pattern>
0N/A
0N/A Options:
0N/A
0N/A -L <url> : URL of the Store. The URL should include
0N/A the password as well (if needed).
0N/A Example: "imap://john:password@mailstore.com"
0N/A -T <protocol> : store protocol (Ex: "imap")
0N/A -H <host> : hostname of store.
0N/A -U <user> : username (if needed)
0N/A -P <passwd> : password (if needed)
0N/A -R <root> : root of the folder hierarchy. This is optional. If
0N/A not present, listing starts from the default folder.
0N/A -r : list recursively - folder and all subfolders.
0N/A -v : verbose - show more info about each folder.
0N/A -D : Turn on session debugging
0N/A <pattern> : folders that match this pattern are listed. Use "*"
0N/A as wildcard to match everything.
0N/A
0N/A
0N/A- monitor.java
0N/A
0N/A Illustrates how to monitor a folder for interesting events,
0N/A like new mail arrival.
0N/A
0N/A Usage:
0N/A java monitor <host> <user> <password> <mbox> <freq>
0N/A
0N/A Arguments (in order):
0N/A
0N/A <host> : hostname of store.
0N/A <user> : username (if needed)
0N/A <passwd> : password (if needed)
0N/A <mbox> : folder to monitor
0N/A <freq> : frequency of monitoring
0N/A
0N/A
0N/A- mover.java
0N/A
0N/A Moves messages between folders. The folders must belong to the
0N/A same store.
0N/A
0N/A Usage:
0N/A java mover -T <protocol> -H <host> -U <user> -P <passwd> [-v]
0N/A -s <src> -d <dest> [-x] <start> <end>
0N/A
0N/A Options:
0N/A
0N/A -T <protocol> : store protocol (Ex: "imap")
0N/A -H <host> : hostname of store.
0N/A -U <user> : username (if needed)
0N/A -P <passwd> : password (if needed)
0N/A -s <src> : source folder
0N/A -d <dest> : destination folder
0N/A -v : Optional verbose option
0N/A -x : Optional expunge option, to expunge the deleted
0N/A messages from src
0N/A
0N/A Arguments (in order):
0N/A
0N/A <start> : start message number
0N/A <end> : end message number
0N/A
0N/A
0N/A- msgmultisendsample.java
0N/A
0N/A Demonstrates how to construct and send a multipart message.
0N/A
0N/A Usage:
0N/A java msgmultisendsample <to> <from> <smtphost> true|false
0N/A
0N/A Arguments (in order):
0N/A
0N/A <to> : Recipient address
0N/A <from> : Sender address
0N/A <smtphost> : name of SMTP server
0N/A true|false : "true" to turn on session debugging, "false" otherwise
0N/A
0N/A
0N/A- msgsend.java
0N/A
0N/A Send a simple text message. Optionally saves a copy
0N/A of the outgoing message in a folder (record-folder).
0N/A
0N/A Most parameters to this program are optional. When
0N/A the program is run, it interactively asks for
0N/A the "To" and "Subject" fields if not already available.
0N/A Then the program expects the body of the message.
0N/A After you type in the body, hit Ctrl-D on Unix
0N/A systems or Ctrl-Z on Windows systems to send
0N/A the message.
0N/A
0N/A Usage:
0N/A java msgsend -L <store-url> -T <protocol> -H <host> -U <user>
0N/A -P <passwd> -s <subject> -o <from> -c <cc> -b <bcc>
0N/A -f <record> -M <smtphost> [-d] <to>
0N/A
0N/A Options:
0N/A
0N/A -L <store-url> : URL of the store for the record-folder
0N/A -T <protocol> : If <store-url> is not present, this indicates
0N/A the store protocol for the record-folder.
0N/A -H <host> : If <store-url> is not present, this indicates
0N/A the hostname for the record-folder.
0N/A -U <user> : If <store-url> is not present, this indicates
0N/A the username for the record-folder.
0N/A -P <passwd> : If <store-url> is not present, this indicates
0N/A the password for the record-folder.
0N/A -f <record> : name of record-folder.
0N/A -M <smtphost> : Host name of SMTP server. Defaults to "localhost"
0N/A which often works on UNIX but rarely on Windows.
0N/A -s <subject> : Subject of message to be sent
0N/A -o <from> : From address of message to be sent
0N/A -c <cc> : Cc address of message to be sent
0N/A -b <bcc> : Bcc address of message to be sent
0N/A -d : Turn on session debugging.
0N/A -a <file> : Include file as an attachment with the message
0N/A
0N/A Argument:
0N/A
0N/A <to> : To address of message to be sent
0N/A
0N/A
0N/A- msgsendsample.java
0N/A
0N/A Demonstrates how to construct and send a simple text message.
0N/A
0N/A Usage:
0N/A java msgsendsample <to> <from> <smtphost> true|false
0N/A
0N/A Arguments (in order):
0N/A
0N/A <to> : Recipient address
0N/A <from> : Sender address
0N/A <smtphost> : name of SMTP server
0N/A true|false : "true" to turn on session debugging, "false" otherwise
0N/A
0N/A
0N/A- msgshow.java
0N/A
0N/A Displays message(s) from a folder or from stdin.
0N/A
0N/A Usage:
0N/A java msgshow -L <url> -T <protocol> -H <host> -p <port>
0N/A -U <user> -P <password> -f <mailbox>
0N/A [-D] [-s] [-S] [-a] [-v] [msgnum]
0N/A java msgshow -m [-D] [-s] [-S] [-v]
0N/A
0N/A Options:
0N/A
0N/A -L <url> : URL of the Store. The URL should include
0N/A the password as well (if needed).
0N/A Example: "imap://john:password@mailstore.com"
0N/A -T <protocol> : If <url> is not present, this indicates
0N/A the store protocol
0N/A -H <host> : If <url> is not present, this indicates
0N/A the hostname
0N/A -p <port> : If <url> is not present, this indicates
0N/A the port number (usually not needed)
0N/A -U <user> : If <url> is not present, this indicates
0N/A the username
0N/A -P <passwd> : If <url> is not present, this indicates
0N/A the password
0N/A -f <mailbox> : Folder to open
0N/A -m : Read message from standard input
0N/A -D : Turn on session debugging
0N/A -s : Show the structure of the message, but not the contents
0N/A -S : Save attachments to appropriately named files
0N/A -a : Show ALERTS and NOTIFICATIONS from the Store
0N/A -v : Verbose mode - show total messages and number of new messages
0N/A
0N/A Argument:
0N/A
0N/A <msgnum> : the message to be displayed. If this
0N/A parameter is not present, all messages in the
0N/A folder are displayed.
0N/A
0N/A
0N/A- namespace.java
0N/A
0N/A Displays the namespaces supported by a store.
0N/A
0N/A Usage:
0N/A java namespace -L <url> -T <protocol> -H <host> -p <port>
0N/A -U <user> -P <password> [-D]
0N/A
0N/A Options:
0N/A
0N/A -L <url> : URL of the Store. The URL should include
0N/A the password as well (if needed).
0N/A Example: "imap://john:password@mailstore.com"
0N/A -T <protocol> : If <url> is not present, this indicates
0N/A the store protocol
0N/A -H <host> : If <url> is not present, this indicates
0N/A the hostname
0N/A -p <port> : If <url> is not present, this indicates
0N/A the port number (usually not needed)
0N/A -U <user> : If <url> is not present, this indicates
0N/A the username
0N/A -P <passwd> : If <url> is not present, this indicates
0N/A the password
0N/A -D : Turn on session debugging
0N/A
0N/A
0N/A- populate.java
0N/A
0N/A Copies an entire folder hierarchy from one message store to
0N/A another.
0N/A
0N/A Usage:
0N/A java populate -s <src-url> -d <dest-url> -D -f
0N/A
0N/A Options:
0N/A
0N/A -s <src-url> : URL of source folder
0N/A -d <dest-url> : URL of destination folder
0N/A -D : Turn on session debugging
0N/A -f : force the copy to occur even if the destination
0N/A folder already exists
0N/A -S : skip special folders named "SCCS", "Drafts", "Trash", and
0N/A "Shared Folders"
0N/A -c : clear out old folders before copying messages
0N/A -P : don't preserve flags when copying messages
0N/A
0N/A
0N/A- registry.java
0N/A
0N/A Demonstrates how to query the JavaMail "registry" for providers,
0N/A set default providers, etc.
0N/A
0N/A Usage:
0N/A java registry
0N/A
0N/A
0N/A- search.java
0N/A
0N/A Search the given folder for messages matching the
0N/A given criteria. Illustrates the use of the
0N/A javax.mail.search package.
0N/A
0N/A Usage:
0N/A java search -L <url> -T <prot> -H <host> -U <user> -P <passwd>
0N/A -f <folder> -subject <subject> -from <from>
0N/A -today -or
0N/A
0N/A Options:
0N/A
0N/A -L <url> : URL of the store
0N/A -T <protocol> : If <url> is not present, this indicates
0N/A the store protocol
0N/A -H <host> : If <url> is not present, this indicates
0N/A the hostname
0N/A -U <user> : If <url> is not present, this indicates
0N/A the username
0N/A -P <passwd> : If <url> is not present, this indicates
0N/A the password
0N/A -f <folder> : folder to search
0N/A
0N/A -or : If this flag is present, the search will
0N/A return messages that match any one of the
0N/A below criteria. Else the search will only
0N/A return messages that match all the criteria
0N/A
0N/A -subject <subject> : search for messages containing this string
0N/A as the Subject
0N/A -from <from> : search for messages containing this string
0N/A as the From address
0N/A -today : search for messages received today
0N/A
0N/A
0N/A- sendfile.java
0N/A
0N/A Send the specified file to the given address. The file
0N/A is sent as an attachment. An SMTP server must be available.
0N/A
0N/A Usage:
0N/A java sendfile <to> <from> <smtphost> <file> true|false
0N/A
0N/A Arguments (in order):
0N/A
0N/A <to> : Recipient address
0N/A <from> : Sender address
0N/A <smtphost> : name of SMTP server
0N/A <file> : name of file to be sent
0N/A true|false : "true" to turn on session debugging, "false" otherwise
0N/A
0N/A
0N/A- sendhtml.java
0N/A
0N/A The sendhtml program works like the msgsend program, taking
0N/A the same options and input, but the text collected from the
0N/A user is sent as type "text/html" instead of "text/plain".
0N/A
0N/A This program is a good example of how to send arbitrary
0N/A string data as any arbitrary MIME type.
0N/A
0N/A
0N/A- smtpsend.java
0N/A
0N/A Takes the same options as the msgsend program, but illustrates
0N/A how to handle SMTP-specific error codes. Also accepts the
0N/A following options:
0N/A
0N/A Option:
0N/A
0N/A -v : verbose output
0N/A -A : use SMTP authentication
0N/A -S : use SSL
0N/A
0N/A- transport.java
0N/A
0N/A Illustrates how to use an explicit Transport object, how to
0N/A handle transport exceptions, and how to handle transport events.
0N/A
0N/A Usage:
0N/A java transport <to> <from> <smtphost> <file> true|false
0N/A
0N/A Arguments (in order):
0N/A
0N/A <to> : Recipient address
0N/A <from> : Sender address
0N/A <smtphost> : name of SMTP server
0N/A <file> : name of file to be sent
0N/A true|false : "true" to turn on session debugging, "false" otherwise
0N/A
0N/A
0N/A- uidmsgshow.java
0N/A
0N/A The uidmsgshow program works like the msgshow program, taking
0N/A the same options, except instead of using message numbers, it
0N/A uses message UID's. This will typically only work with IMAP
0N/A message stores.