You want a way to automatically provide server host, protocol, user, and password.
You may remember from Section 7.8 that
is a list of name/value pairs, and that
Properties to provide loading and saving. In
several places in this chapter, I use a
FileProperties object to preload a large variety
of settings, instead of hardcoding them or having to type them all on
the command line. When dealing with JavaMail, you must specify the mail
hostname, username and password, protocol to use (IMAP, POP, or
mailbox for reading), and so on. I store this information in a
properties file, and most of the programs in this chapter will use
it. Here is my default file,
# This file contains my default Mail properties. # # Values for sending Mail.email@example.com Mail.send.proto=smtp Mail.send.host=localhost Mail.send.debug=true # # Values for receiving Mail.receive.host=localhost Mail.receive.protocol=mbox Mail.receive.user=* Mail.receive.pass=* Mail.receive.root=/var/mail/ian
The last two,
can have certain predefined values. Since nobody concerned with
security would store unencrypted passwords in a file on disk, I allow
you to set
pass=ASK (in uppercase), which causes
some of my programs to prompt for a password. The JavaMail API allows
root=INBOX to mean the default storage
location for your mail.
The keys in this list of ...