MailSessionFactory (Apache Tomcat 11.0.21 API Documentation)
Description: declaration: package: org.apache.naming.factory, class: MailSessionFactory

# Class MailSessionFactory

java.lang.Object
org.apache.naming.factory.MailSessionFactory

All Implemented Interfaces:
  `ObjectFactory`

public class MailSessionFactory extends Object implements ObjectFactory

Factory class that creates a JNDI named JavaMail Session factory, which can be used for managing inbound and outbound electronic mail messages via JavaMail APIs. All messaging environment properties described in the JavaMail Specification may be passed to the Session factory; however the following properties are the most commonly used:

- mail.smtp.host - Hostname for outbound transport connections. Defaults to `localhost` if not specified.

This factory can be configured in a `<Context>` element in your `conf/server.xml` configuration file. An example of factory configuration is:

    <Resource name="mail/smtp"
              auth="CONTAINER"
              type="jakarta.mail.Session"
              mail.smtp.host="mail.mycompany.com"
              />

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected static final String`
  `factoryType`
  The Java type for which this factory knows how to create objects.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MailSessionFactory()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `getObjectInstance(Object refObj, Name name, Context context, Hashtable<?,?> env)`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### factoryType

    protected static final String factoryType
    The Java type for which this factory knows how to create objects.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### MailSessionFactory

    public MailSessionFactory()

- ## Method Details

  - ### getObjectInstance

    public Object getObjectInstance(Object refObj, Name name, Context context, Hashtable<?,?> env) throws Exception
    Specified by:
      `getObjectInstance` in interface `ObjectFactory`
    Throws:
      `Exception`