server.js
function setupListener (host_port, listenerDone) {

            const hp = /^\[?([^\]]+)\]?:(\d+)$/.exec(host_port);
            if (!hp) return listenerDone(
                new Error('Invalid "listen" format in smtp.ini'));

            const host = hp[1];
            const port = parseInt(hp[2], 10);

            Server.get_smtp_server(host, port, inactivity_timeout, (server) => {
                if (!server) return listenerDone();

                server.notes = Server.notes;
                if (Server.cluster) server.cluster = Server.cluster;

                server
                    .on('listening', function () {
                        const addr = this.address();
                        logger.lognotice(`Listening on ${addr.address}:${addr.port}`);
                        listenerDone();
                    })
                    .on('close', () => {
                        logger.loginfo(`Listener ${host}:${port} stopped`);
                    })
                    .on('error', e => {
                        if (e.code !== 'EAFNOSUPPORT') return listenerDone(e);
                        // Fallback from IPv6 to IPv4 if not supported
                        // But only if we supplied the default of [::0]:25
                        if (/^::0/.test(host) && Server.default_host) {
                            server.listen(port, '0.0.0.0', 0);
                            return;
                        }
                        // Pass error to callback
                        listenerDone(e);
                    })
                    .listen(port, host, 0);
            });
        }
function setupListener (host_port, listenerDone) {

            const hp = /^\[?([^\]]+)\]?:(\d+)$/.exec(host_port);
            if (!hp) return listenerDone(
                new Error('Invalid "listen" format in smtp.ini'));

            const host = hp[1];
            const port = parseInt(hp[2], 10);

            Server.get_smtp_server(host, port, inactivity_timeout, (server) => {
                if (!server) return listenerDone();

                server.notes = Server.notes;
                if (Server.cluster) server.cluster = Server.cluster;

                server
                    .on('listening', function () {
                        const addr = this.address();
                        logger.lognotice(`Listening on ${addr.address}:${addr.port}`);
                        listenerDone();
                    })
                    .on('close', () => {
                        logger.loginfo(`Listener ${host}:${port} stopped`);
                    })
                    .on('error', e => {
                        if (e.code !== 'EAFNOSUPPORT') return listenerDone(e);
                        // Fallback from IPv6 to IPv4 if not supported
                        // But only if we supplied the default of [::0]:25
                        if (/^::0/.test(host) && Server.default_host) {
                            server.listen(port, '0.0.0.0', 0);
                            return;
                        }
                        // Pass error to callback
                        listenerDone(e);
                    })
                    .listen(port, host, 0);
            });
        }
function setupListener ( host_port , listenerDone ) { const hp = / ^\[?([^\]]+)\]?:(\d+)$ / . exec ( host_port ) ; if ( ! hp ) return listenerDone ( new Error ( 'Invalid "listen" format in smtp.ini' ) ) ; const host = hp [ 1 ] ; const port = parseInt ( hp [ 2 ] , 10 ) ; Server . get_smtp_server ( host , port , inactivity_timeout , ( server ) => { if ( ! server ) return listenerDone ( ) ; server . notes = Server . notes ; if ( Server . cluster ) server . cluster = Server . cluster ; server . on ( 'listening' , function ( ) { const addr = this . address ( ) ; logger . lognotice ( ` ${ addr . address } ${ addr . port } ` ) ; listenerDone ( ) ; } ) . on ( 'close' , ( ) => { logger . loginfo ( ` ${ host } ${ port } ` ) ; } ) . on ( 'error' , e => { if ( e . code !== 'EAFNOSUPPORT' ) return listenerDone ( e ) ; // Fallback from IPv6 to IPv4 if not supported // But only if we supplied the default of [::0]:25 if ( / ^::0 / . test ( host ) && Server . default_host ) { server . listen ( port , '0.0.0.0' , 0 ) ; return ; } // Pass error to callback listenerDone ( e ) ; } ) . listen ( port , host , 0 ) ; } ) ; }
array of listeners
array of listeners