Example usage for javax.mail Transport addConnectionListener

List of usage examples for javax.mail Transport addConnectionListener

Introduction

In this page you can find the example usage for javax.mail Transport addConnectionListener.

Prototype

public void addConnectionListener(ConnectionListener l) 

Source Link

Document

Add a listener for Connection events on this service.

Usage

From source file:com.googlecode.gmail4j.javamail.ImapGmailConnection.java

/**
 * Gets Gmail {@link Transport}//from www . j a v  a  2 s .  com
 *
 * @return Configured and ready for use Transport
 */
public Transport getTransport() {
    try {
        final Transport transport = getSession().getTransport();
        transport.addConnectionListener(new ImapConnectionHandler(
                new ConnectionInfo(loginCredentials.getUsername(), gmailSmtpHost, gmailSmtpPort)));
        transport.connect(loginCredentials.getUsername(), new String(loginCredentials.getPasword()));
        return transport;
    } catch (final Exception e) {
        throw new GmailException("ImapGmailClient requires ImapGmailConnection!");
    }
}