NewJavaLearner wrote:
> Hi all,
> i want to send from a servlet a mail for this adress myadress_at_domain.com.
> How can i use mail ressources to connect to an smtp server of course with
> authentification.
> Thanks for yor help.
The JavaMail download package at
http://java.sun.com/products/javamail
has instructions and sample programs. And there's information in the
JavaMail FAQ.
Under GlassFish, the mail Session can be provided as a resource.
You'll probably need to configure the Session with additional properties
described in the JavaMail documentation. (Although a vaguely remember
there being a bug with the use of additional mail session properties
in GlassFish, but I don't remember which version and whether it's fixed
in the latest version.)
Given the configured mail session, you can use it to get a Transport
object, on which you can call the connect method, supplying the needed
username and password to authenticate to your server.