Sun Java Solaris Communities My SDN Account Join SDN
 
Tutorials

jGuru: Fundamentals of the JavaMail API

 


[Help | API Docs | Short Course| Exercises]

In this exercise you will install Sun's JavaMail reference implementation. After installing, you will be introduced to the demonstration programs that come with the reference implementation.

Tasks


  1. Download the latest version of the JavaMail API implementation from Sun.

  2. Download the latest version of the JavaBeans Activation Framework from Sun.

  3. Unzip the downloaded packages. You get a ZIP file for all platforms for both packages.

  4. Add the mail.jar file from the JavaMail download and the activation.jar file from the JavaBeans Activation Framework download to your CLASSPATH.

  5. Go into the demo directory that comes with the JavaMail API implementation and compile the msgsend program to send a test message.

  6. Execute the program passing in a from address with the -o option, your SMTP server with the -M option, and the to address (with no option). You'll then enter the subject, the text of your message, and the end-of-file character (CTRL-Z) to signal the end of the message input.

  7. Check to make sure you received the message with your normal mail reader (Eudora, Outlook Express, pine, ...).

Where help exists, the task numbers above are linked to the step-by-step help page.

Solution Source

Upon successful completion, the JavaMail reference implementation will be in your CLASSPATH.

Demonstration

After executing the following command (replacing the email addresses and specifying your SMTP server):

[prompt] java msgsend -o from@address -M SMTP.Server to@address

You enter a subject and the message, ending the message with CTRL-Z.

Subject: Hi
Welcome
^Z

Assuming your CLASSPATH is set properly and your mail server will let you send mail, you'll get the following message displayed:

Mail was sent successfully.

Next Exercise

Exercises

About This Short Course

Copyright 1996-2001 jGuru.com. All Rights Reserved.