Search in sources :

Example 1 with PopClient

use of lucee.runtime.net.pop.PopClient in project Lucee by lucee.

the class MailClient method getInstance.

public static MailClient getInstance(int type, String server, int port, String username, String password, boolean secure, String name, String id) throws Exception {
    String uid;
    if (StringUtil.isEmpty(name))
        uid = createName(type, server, port, username, password, secure);
    else
        uid = name;
    uid = type + ";" + uid + ";" + id;
    PoolItem item = pool.get(uid);
    if (item == null) {
        if (StringUtil.isEmpty(server)) {
            if (StringUtil.isEmpty(name))
                throw new ApplicationException("missing server information");
            else
                throw new ApplicationException("there is no connection available with name [" + name + "]");
        }
        if (TYPE_POP3 == type)
            pool.put(uid, item = new PopClient(server, port, username, password, secure));
        if (TYPE_IMAP == type)
            pool.put(uid, item = new ImapClient(server, port, username, password, secure));
    }
    return (MailClient) item;
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) ImapClient(lucee.runtime.net.imap.ImapClient) PopClient(lucee.runtime.net.pop.PopClient) PoolItem(lucee.runtime.pool.PoolItem)

Aggregations

ApplicationException (lucee.runtime.exp.ApplicationException)1 ImapClient (lucee.runtime.net.imap.ImapClient)1 PopClient (lucee.runtime.net.pop.PopClient)1 PoolItem (lucee.runtime.pool.PoolItem)1