⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smtpserver.java

📁 java 开发的邮件服务器平台。支持以下协议。 协议可以修改为自己的专门标识
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                getLogger().info("The maximum allowed message size is " + maxMessageSize + " bytes.");            } else {                getLogger().info("No maximum message size is enforced for this server.");            }            // How many bytes to read before updating the timer that data is being transfered            lengthReset = configuration.getChild("lengthReset").getValueAsInteger(lengthReset);            if (lengthReset <= 0) {                throw new ConfigurationException("The configured value for the idle timeout reset, " + lengthReset + ", is not valid.");            }            if (getLogger().isInfoEnabled()) {                getLogger().info("The idle timeout will be reset every " + lengthReset + " bytes.");            }        } else {            mailetcontext.setAttribute(Constants.HELLO_NAME, "localhost");        }    }    /**     * @see org.apache.avalon.framework.activity.Initializable#initialize()     */    public void initialize() throws Exception {        super.initialize();        if (!isEnabled()) {            return;        }        if (connectionLimit != null) {            theHandlerPool = new HardResourceLimitingPool(theHandlerFactory, 5, connectionLimit.intValue());            if (getLogger().isDebugEnabled()) {                getLogger().debug("Using a bounded pool for SMTP handlers with upper limit " + connectionLimit.intValue());            }        } else {            // NOTE: The maximum here is not a real maximum.  The handler pool will continue to            //       provide handlers beyond this value.            theHandlerPool = new DefaultPool(theHandlerFactory, null, 5, 30);            getLogger().debug("Using an unbounded pool for SMTP handlers.");        }        if (theHandlerPool instanceof LogEnabled) {            ((LogEnabled)theHandlerPool).enableLogging(getLogger());        }        if (theHandlerPool instanceof Initializable) {            ((Initializable)theHandlerPool).initialize();        }        theWatchdogFactory = getWatchdogFactory();    }    /**     * @see org.apache.james.core.AbstractJamesService#getDefaultPort()     */     protected int getDefaultPort() {        return 25;     }    /**     * @see org.apache.james.core.AbstractJamesService#getServiceType()     */    public String getServiceType() {        return "SMTP Service";    }    /**     * @see org.apache.avalon.cornerstone.services.connection.AbstractHandlerFactory#newHandler()     */    protected ConnectionHandler newHandler()            throws Exception {        SMTPHandler theHandler = (SMTPHandler)theHandlerPool.get();        if (getLogger().isDebugEnabled()) {            getLogger().debug("Getting SMTPHandler from pool.");        }        Watchdog theWatchdog = theWatchdogFactory.getWatchdog(theHandler.getWatchdogTarget());        theHandler.setConfigurationData(theConfigData);        theHandler.setWatchdog(theWatchdog);        return theHandler;    }    /**     * @see org.apache.avalon.cornerstone.services.connection.ConnectionHandlerFactory#releaseConnectionHandler(ConnectionHandler)     */    public void releaseConnectionHandler( ConnectionHandler connectionHandler ) {        if (!(connectionHandler instanceof SMTPHandler)) {            throw new IllegalArgumentException("Attempted to return non-SMTPHandler to pool.");        }        if (getLogger().isDebugEnabled()) {            getLogger().debug("Returning SMTPHandler to pool.");        }        theHandlerPool.put((Poolable)connectionHandler);    }    /**     * The factory for producing handlers.     */    private static class SMTPHandlerFactory        implements ObjectFactory {        /**         * @see org.apache.avalon.excalibur.pool.ObjectFactory#newInstance()         */        public Object newInstance() throws Exception {            return new SMTPHandler();        }        /**         * @see org.apache.avalon.excalibur.pool.ObjectFactory#getCreatedClass()         */        public Class getCreatedClass() {            return SMTPHandler.class;        }        /**         * @see org.apache.avalon.excalibur.pool.ObjectFactory#decommision(Object)         */        public void decommission( Object object ) throws Exception {            return;        }    }    /**     * A class to provide SMTP handler configuration to the handlers     */    private class SMTPHandlerConfigurationDataImpl        implements SMTPHandlerConfigurationData {        /**         * @see org.apache.james.smtpserver.SMTPHandlerConfigurationData#getHelloName()         */        public String getHelloName() {            return SMTPServer.this.helloName;        }        /**         * @see org.apache.james.smtpserver.SMTPHandlerConfigurationData#getResetLength()         */        public int getResetLength() {            return SMTPServer.this.lengthReset;        }        /**         * @see org.apache.james.smtpserver.SMTPHandlerConfigurationData#getMaxMessageSize()         */        public long getMaxMessageSize() {            return SMTPServer.this.maxMessageSize;        }        /**         * @see org.apache.james.smtpserver.SMTPHandlerConfigurationData#isAuthRequired(String)         */        public boolean isRelayingAllowed(String remoteIP) {            boolean relayingAllowed = false;            if (authorizedNetworks != null) {                relayingAllowed = SMTPServer.this.authorizedNetworks.matchInetNetwork(remoteIP);            }            return relayingAllowed;        }        /**         * @see org.apache.james.smtpserver.SMTPHandlerConfigurationData#isAuthRequired(String)         */        public boolean isAuthRequired(String remoteIP) {            boolean authRequired = SMTPServer.this.authRequired;            if (authorizedNetworks != null) {                authRequired = authRequired && !SMTPServer.this.authorizedNetworks.matchInetNetwork(remoteIP);            }            return authRequired;        }        /**         * @see org.apache.james.smtpserver.SMTPHandlerConfigurationData#isAuthRequired()         */        public boolean isAuthRequired() {            return SMTPServer.this.authRequired;        }        /**         * @see org.apache.james.smtpserver.SMTPHandlerConfigurationData#isVerifyIdentity()         */        public boolean isVerifyIdentity() {            return SMTPServer.this.verifyIdentity;        }        /**         * @see org.apache.james.smtpserver.SMTPHandlerConfigurationData#getMailServer()         */        public MailServer getMailServer() {            return SMTPServer.this.mailServer;        }        /**         * @see org.apache.james.smtpserver.SMTPHandlerConfigurationData#getUsersRepository()         */        public UsersRepository getUsersRepository() {            return SMTPServer.this.users;        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -