First I would like to say that writing a decent email server or chat server (and
clients) are each significant projects
on their own. If you really must tackle both (especially after only programming
in Java for a few months) then you will
need to understand that it is a significant amount of work and it will be an
uphill battle. Understand that I am not
trying to discourage you, rather I am trying to give you a little dose of
reality - what you are talking about doing is
difficult.
Now, on to your questions: You can store your data anywhere. You may want to do
a mixture of database and flat files
(i.e. database for storing friend lists and flat files for the text of
particular chat discussions.) For supporting
MIME I would suggest looking at the JavaMail API from Sun. It contains most of
the tools necessary to handle MIME
messages. However actually writing an SMTP/POP/IMAP server is going to require
actually getting into the different
protocols.
Finally, I would suggest that you do some serious research and see if the
programs you are planning on writing already
exist. For your mail server, perhaps you should look at James (
http://jakarta.apache.org/james ).