Setting up a JavaMail Session Resource on the GlassFish Application Server

See Also

The JavaMail API is a set of abstract APIs that model a mail system. The API provides a platform-independent and protocol-independent framework to build mail and messaging applications. The JavaMail API provides facilities for reading and sending email. Service providers implement particular protocols.

The JavaMail API is implemented as a Java platform optional package and is also available as part of the Java EE platform.

To create a JavaMail Session resource:

  1. Go to File > New (Ctrl-N).
  2. In the Project combo box, choose either your EJBModule or WebModule.
  3. Select GlassFish in the Categories pane, JavaMail Session in the File Types pane, and click Next.
  4. (required) Enter a JNDI name for the resource.
  5. (required) In the mail host field, enter the DNS name of the default mail server.
  6. (required) In the default user field, enter the user name to use when connecting to the mail server.
  7. (required) In the Default Return Address field, enter the email address of the default user, in the form username@host.domain.
  8. Enable or disable the resource by choosing true or false.
  9. Enter a description.
  10. In the Advanced area, change the field values only if the server's mail provider has been reconfigured to use a nondefault store or transport protocol. Select True for Debug Enabled for extra debugging output.
  11. Click Next.
  12. Enter any properties for the resource.
  13. Click Finish.

When you complete the wizard, the resource properties are added to sun-resources.xml. If you need to edit the properties of the resource, you can open sun-resources.xml in the Source Editor by expanding the Server Resources node of your project in the Projects window and double-clicking the file.

Once you have created the object in your project, the resource needs to be registered with the server before you can use it. The resource is automatically registered when you deploy your project.

For more on the Sun JavaMail API, see:

See Also
Registering a Resource with the GlassFish Application Server

Legal Notices