public static void startWithAuth(int port) { SMTPServer server = new SMTPServer(new SimpleMessageListenerAdapter(new MyMessageListener())); server.setPort(port); UsernamePasswordValidator validator = (s, s1) -> { if (!"username".equalsIgnoreCase(s) || !"password".equalsIgnoreCase(s1)) { throw new LoginFailedException(); } }; server.setAuthenticationHandlerFactory(new PlainAuthenticationHandlerFactory(validator)); server.start(); }
@Override public void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory) throws ProcessException { if (smtp == null) { try { final SMTPServer server = prepareServer(context, sessionFactory); server.start(); getLogger().debug("Started SMTP Server on port " + server.getPort()); smtp = server; } catch (final Exception ex) {//have to catch exception due to awkward exception handling in subethasmtp smtp = null; getLogger().error("Unable to start SMTP server due to " + ex.getMessage(), ex); } } context.yield();//nothing really to do here since threading managed by smtp server sessions }
public static void start(int port) { SMTPServer smtpServer = new SMTPServer(new SimpleMessageListenerAdapter(new MyMessageListener())); smtpServer.setPort(port); smtpServer.start(); }
/** * Starts the server on the port and address specified in parameters. * * @param port the SMTP port to be opened. * @param bindAddress the address to bind to. null means bind to all. * @throws BindPortException when the port can't be opened. * @throws OutOfRangePortException when port is out of range. * @throws IllegalArgumentException when port is out of range. */ public void startServer(int port, InetAddress bindAddress) throws BindPortException, OutOfRangePortException { LOGGER.debug("Starting server on port {}", port); try { smtpServer.setBindAddress(bindAddress); smtpServer.setPort(port); smtpServer.start(); } catch (RuntimeException exception) { if (exception.getMessage().contains("BindException")) { // Can't open port LOGGER.error("{}. Port {}", exception.getMessage(), port); throw new BindPortException(exception, port); } else if (exception.getMessage().contains("out of range")) { // Port out of range LOGGER.error("Port {} out of range.", port); throw new OutOfRangePortException(exception, port); } else { // Unknown error LOGGER.error("", exception); throw exception; } } }
/** * Starts the SMTP Server */ public void start() { this.server.start(); }
/** Starts the SMTP Server */ public void start() { this.server.start(); }
import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; @WebListener public class Initializer implements ServletContextListener { @Override public final void contextInitialized(final ServletContextEvent sce) { SMTPServer smtp_server = SMTPServer.getInstance(); smtp_server.start(); } }
/** Starts the SMTP Server */ public void start() { this.server.start(); }
/** Starts the SMTP Server */ public void start() { this.server.start(); }
/** Starts the SMTP Server */ public void start() { this.server.start(); }
import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.ejb.Startup; import javax.ejb.Singleton; @Singleton @Startup public class InitializerEjb { @PostConstruct public void init() { SMTPServer smtp_server = SMTPServer.getInstance(); smtp_server.start(); } }
public void start() { smtpServer.start(); log.info("SMTP started"); }
public void doTest() throws Exception { Wiser wiser = new Wiser(); SMTPServer smtpServer = createServer(new SimpleMessageListenerAdapter(wiser)); smtpServer.setHostName("localhost"); smtpServer.setPort(5000); TestPluginLifeCycle lifeCycle = createLifeCycle(); try { lifeCycle.start(); smtpServer.start(); execute(lifeCycle, wiser); } finally { smtpServer.stop(); lifeCycle.stop(); } } }
public void start() { // start the smtp server! SMTPServer server = new SMTPServer(handlerFactory); server.setSoftwareName("MockMock SMTP Server version " + AppStarter.VERSION_NUMBER); server.setPort(port); try { System.out.println("Starting MockMock on port " + port); server.start(); } catch (Exception e) { System.err.println("Could not start MockMock. Maybe port " + port + " is already in use?"); } } }
@Override public void start() { initSmtpReceiver(); log.info("starting SMTP server on port: " + this.smtpReceivingServer.getPort() + " address: " + this.smtpReceivingServer.getBindAddress()); try { this.smtpReceivingServer.start(); } catch (Throwable e) { throw new RuntimeException("Exception starting SMTP server. port: " + this.smtpReceivingServer.getPort() + " address: " + this.smtpReceivingServer.getBindAddress(), e); } log.info("Geroa email server started."); }
public SMTPServer start(int port) { BasicMessageHandlerFactory myFactory = new BasicMessageHandlerFactory(); SMTPServer smtpServer = SMTPServer.port(port).messageHandlerFactory(myFactory).build(); System.out.println("Starting Basic SMTP Server on port " + port + "..."); smtpServer.start(); return smtpServer; }
@Override @SuppressWarnings("PMD.ShortMethodName") public void run(ApplicationArguments args) { SMTPServer server = new SMTPServer(new SimpleMessageListenerAdapter(new SimpleMessageListener() { @Override public boolean accept(String from, String recipient) { return true; } @Override public void deliver(String from, String recipient, InputStream data) throws IOException { log.info(IOUtils.toString(data, UTF_8)); } })); server.setPort(port); server.start(); } }
@Override public void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory) throws ProcessException { if (smtp == null) { try { final SMTPServer server = prepareServer(context, sessionFactory); server.start(); getLogger().debug("Started SMTP Server on port " + server.getPort()); smtp = server; } catch (final Exception ex) {//have to catch exception due to awkward exception handling in subethasmtp smtp = null; getLogger().error("Unable to start SMTP server due to " + ex.getMessage(), ex); } } context.yield();//nothing really to do here since threading managed by smtp server sessions }
/** * Start the SMTP Embedded Server; called by the container during deployment * * @throws Exception */ @PostConstruct public void startup() throws Exception { server = new SMTPServer(new SimpleMessageListenerAdapter(listener)); server.setBindAddress(InetAddress.getLoopbackAddress()); server.setPort(BIND_PORT); server.start(); }
@Override public void startup() { serverImpl = new SMTPServer(new HandlerFactory()); // MER - May need to override SMTPServer.createSSLSocket to specify non default keystore. serverImpl.setPort(getPort()); serverImpl.setHostName(getDomain()); serverImpl.setMaxConnections(getMaxConnections()); serverImpl.setHideTLS(isHideTLS()); serverImpl.setEnableTLS(isEnableTLS()); serverImpl.setRequireTLS(isRequireTLS()); if(isAuthenticate()) { AuthenticationHandlerFactory authenticationHandler = new EasyAuthenticationHandlerFactory(new AlfrescoLoginUsernamePasswordValidator()); serverImpl.setAuthenticationHandlerFactory(authenticationHandler); } serverImpl.start(); log.info("Inbound SMTP Email Server has started successfully, on hostName:" + getDomain() + "port:" + getPort()); }