Use the create-javamail-resource subcommand in remote mode to create a JavaMail session resource. The JNDI name for a JavaMail session resource customarily includes the mail/ naming subcontext, For example: mail/MyMailSession.
Ensure that the server is running.
Remote subcommands require a running server.
Create a JavaMail resource by using the create-javamail-resource(1) subcommand.
Information about the properties for the subcommand is included in this help page.
To apply your changes, restart GlassFish Server.
See To Restart a Domain.
This example creates a JavaMail resource named mail/MyMailSession. The escape character (\) is used in the --fromaddress option to distinguish the dot (.) and at sign (@).
asadmin> create-javamail-resource --mailhost localhost --mailuser sample --fromaddress sample\@sun\.com mail/MyMailSession Command create-javamail-resource executed successfully.
You can also view the full syntax and options of the subcommand by typing asadmin help create-javamail-resource at the command line.