Search in sources :

Example 6 with ServerImpl

use of lucee.runtime.net.mail.ServerImpl in project Lucee by lucee.

the class SMTPClient method toServerImpl.

public static ServerImpl toServerImpl(String server, int port, String usr, String pwd, long lifeTimespan, long idleTimespan) throws MailException {
    int index;
    // username/password
    index = server.indexOf('@');
    if (index != -1) {
        usr = server.substring(0, index);
        server = server.substring(index + 1);
        index = usr.indexOf(':');
        if (index != -1) {
            pwd = usr.substring(index + 1);
            usr = usr.substring(0, index);
        }
    }
    // port
    index = server.indexOf(':');
    if (index != -1) {
        try {
            port = Caster.toIntValue(server.substring(index + 1));
        } catch (ExpressionException e) {
            throw new MailException(e.getMessage());
        }
        server = server.substring(0, index);
    }
    ServerImpl srv = ServerImpl.getInstance(server, port, usr, pwd, lifeTimespan, idleTimespan, false, false);
    return srv;
}
Also used : ServerImpl(lucee.runtime.net.mail.ServerImpl) MailException(lucee.runtime.net.mail.MailException) ExpressionException(lucee.runtime.exp.ExpressionException)

Aggregations

ServerImpl (lucee.runtime.net.mail.ServerImpl)6 Server (lucee.runtime.net.mail.Server)4 ExpressionException (lucee.runtime.exp.ExpressionException)2 PageException (lucee.runtime.exp.PageException)2 MailException (lucee.runtime.net.mail.MailException)2 FileNotFoundException (java.io.FileNotFoundException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 MessagingException (javax.mail.MessagingException)1 lucee.aprint (lucee.aprint)1 Log (lucee.commons.io.log.Log)1 Resource (lucee.commons.io.res.Resource)1 SerializableObject (lucee.commons.lang.SerializableObject)1 Component (lucee.runtime.Component)1 ComponentSpecificAccess (lucee.runtime.ComponentSpecificAccess)1 PageContextImpl (lucee.runtime.PageContextImpl)1 CacheConnection (lucee.runtime.cache.CacheConnection)1 ConfigImpl (lucee.runtime.config.ConfigImpl)1