Example usage for javax.mail Session setProtocolForAddress

List of usage examples for javax.mail Session setProtocolForAddress

Introduction

In this page you can find the example usage for javax.mail Session setProtocolForAddress.

Prototype

public synchronized void setProtocolForAddress(String addresstype, String protocol) 

Source Link

Document

Set the default transport protocol to use for addresses of the specified type.

Usage

From source file:org.nuxeo.ecm.platform.ec.notification.email.EmailHelper.java

/**
 * Instantiate a new session that authenticate given the protocol's properties. Initialize also the default
 * transport protocol handler according to the properties.
 *
 * @since 5.6/*from  w  ww  .  ja v  a 2  s . co m*/
 */
public static Session newSession(Properties props) {
    Authenticator authenticator = new EmailAuthenticator(props);
    Session session = Session.getDefaultInstance(props, authenticator);
    String protocol = props.getProperty("mail.transport.protocol");
    if (protocol != null && protocol.length() > 0) {
        session.setProtocolForAddress("rfc822", protocol);
    }
    return session;
}