Java Code Examples for org.subethamail.smtp.server.SMTPServer#setPort()
The following examples show how to use
org.subethamail.smtp.server.SMTPServer#setPort() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SubethaEmailServer.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@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()); }
Example 2
Source File: SakaiMessageHandlerFactory.java From sakai with Educational Community License v2.0 | 6 votes |
public void init() { Objects.requireNonNull(rb, "ResourceLoader must be set"); Objects.requireNonNull(serverConfigurationService, "ServerConfigurationService must be set"); Objects.requireNonNull(entityManager, "EntityManager must be set"); Objects.requireNonNull(aliasService, "AliasService must be set"); Objects.requireNonNull(userDirectoryService, "UserDirectoryService must be set"); Objects.requireNonNull(siteService, "SiteService must be set"); Objects.requireNonNull(threadLocalManager, "ThreadLocalManager must be set"); Objects.requireNonNull(contentHostingService, "ContentHostingService must be set"); Objects.requireNonNull(mailArchiveService, "MailArchiveService must be set"); Objects.requireNonNull(sessionManager, "SessionManager must be set"); if (serverConfigurationService.getBoolean("smtp.enabled", false)) { server = new SMTPServer(this); server.setHostName(serverConfigurationService.getServerName()); server.setPort(serverConfigurationService.getInt("smtp.port", 25)); server.setSoftwareName("SubEthaSMTP - Sakai (" + serverConfigurationService.getString("sakai.version", "unknown") + ")"); // We don't support smtp.dns.1 and smtp.dns.2 server.setMaxConnections(100); server.start(); } }
Example 3
Source File: SakaiMessageHandlerFactory.java From sakai with Educational Community License v2.0 | 6 votes |
public void init() { Objects.requireNonNull(rb, "ResourceLoader must be set"); Objects.requireNonNull(serverConfigurationService, "ServerConfigurationService must be set"); Objects.requireNonNull(entityManager, "EntityManager must be set"); Objects.requireNonNull(aliasService, "AliasService must be set"); Objects.requireNonNull(userDirectoryService, "UserDirectoryService must be set"); Objects.requireNonNull(siteService, "SiteService must be set"); Objects.requireNonNull(threadLocalManager, "ThreadLocalManager must be set"); Objects.requireNonNull(contentHostingService, "ContentHostingService must be set"); Objects.requireNonNull(mailArchiveService, "MailArchiveService must be set"); Objects.requireNonNull(sessionManager, "SessionManager must be set"); if (serverConfigurationService.getBoolean("smtp.enabled", false)) { server = new SMTPServer(this); server.setHostName(serverConfigurationService.getServerName()); server.setPort(serverConfigurationService.getInt("smtp.port", 25)); server.setSoftwareName("SubEthaSMTP - Sakai (" + serverConfigurationService.getString("sakai.version", "unknown") + ")"); // We don't support smtp.dns.1 and smtp.dns.2 server.setMaxConnections(100); server.start(); } }
Example 4
Source File: AwsSmtpRelay.java From aws-smtp-relay with GNU Lesser General Public License v3.0 | 5 votes |
void run() throws UnknownHostException { String bindAddress = cmd.hasOption("b") ? cmd.getOptionValue("b") : "127.0.0.1"; SMTPServer smtpServer = new SMTPServer(new SimpleMessageListenerAdapter(this)); smtpServer.setBindAddress(InetAddress.getByName(bindAddress)); if (cmd.hasOption("p")) { smtpServer.setPort(Integer.parseInt(cmd.getOptionValue("p"))); } else { smtpServer.setPort(10025); } smtpServer.start(); }
Example 5
Source File: SmtpServerConfigurator.java From fake-smtp-server with Apache License 2.0 | 5 votes |
public void configure(SMTPServer smtpServer) { smtpServer.setPort(fakeSmtpConfigurationProperties.getPort()); smtpServer.setBindAddress(fakeSmtpConfigurationProperties.getBindAddress()); if (fakeSmtpConfigurationProperties.getAuthentication() != null) { configureAuthentication(smtpServer, fakeSmtpConfigurationProperties.getAuthentication()); } }
Example 6
Source File: HoldMailSMTPServer.java From holdmail with Apache License 2.0 | 5 votes |
@PostConstruct public void startup() { smtpServer = new SMTPServer(handlerFactory); smtpServer.setSoftwareName(HoldMailSMTPServer.class.getSimpleName() + " SMTP"); smtpServer.setPort(smtpServerPort); smtpServer.start(); }
Example 7
Source File: TestMailManager.java From entando-components with GNU Lesser General Public License v3.0 | 5 votes |
public void testSendMailWithChangedPort() throws Throwable { MockMessageHandlerFactory myFactory2 = new MockMessageHandlerFactory(); MockAuthenticationHandlerFactory myAuthFactory2 = new MockAuthenticationHandlerFactory(); SMTPServer smtpServer2 = new SMTPServer(myFactory2, myAuthFactory2); smtpServer2.setPort(25001); smtpServer2.start(); MailConfig originaryConfig = this._mailManager.getMailConfig(); try { MailConfig config = this._mailManager.getMailConfig(); config.setSmtpPort(25001); this._mailManager.updateMailConfig(config); String[] mailAddresses = JpmailTestHelper.MAIL_ADDRESSES; this._mailManager.sendMail(MAIL_TEXT, "Mail semplice", mailAddresses, mailAddresses, mailAddresses, SENDER_CODE); } catch (Throwable t) { throw t; } finally { this._mailManager.updateMailConfig(originaryConfig); this.checkOriginaryConfig(originaryConfig); } myFactory2 = null; myAuthFactory2 = null; smtpServer2.stop(); smtpServer2 = null; }
Example 8
Source File: SslMailServer.java From keycloak with Apache License 2.0 | 5 votes |
public static void start() { smtpServer = new SMTPServer(messageHandlerFactory); smtpServer.setHostName(HOST); smtpServer.setPort(Integer.parseInt(PORT)); smtpServer.start(); log.info("Started mail server (" + smtpServer.getHostName() + ":" + smtpServer.getPort() + ")"); }
Example 9
Source File: ListenSMTP.java From localization_nifi with Apache License 2.0 | 4 votes |
private SMTPServer prepareServer(final ProcessContext context, final ProcessSessionFactory sessionFactory) { final int port = context.getProperty(SMTP_PORT).asInteger(); final String host = context.getProperty(SMTP_HOSTNAME).getValue(); final ComponentLog log = getLogger(); final int maxMessageSize = context.getProperty(SMTP_MAXIMUM_MSG_SIZE).asDataSize(DataUnit.B).intValue(); //create message handler factory final MessageHandlerFactory messageHandlerFactory = (final MessageContext mc) -> { return new SmtpConsumer(mc, sessionFactory, port, host, log, maxMessageSize); }; //create smtp server final SSLContextService sslContextService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class); final SMTPServer smtpServer = sslContextService == null ? new SMTPServer(messageHandlerFactory) : new SMTPServer(messageHandlerFactory) { @Override public SSLSocket createSSLSocket(Socket socket) throws IOException { InetSocketAddress remoteAddress = (InetSocketAddress) socket.getRemoteSocketAddress(); String clientAuth = context.getProperty(CLIENT_AUTH).getValue(); SSLContext sslContext = sslContextService.createSSLContext(SSLContextService.ClientAuth.valueOf(clientAuth)); SSLSocketFactory socketFactory = sslContext.getSocketFactory(); SSLSocket sslSocket = (SSLSocket) (socketFactory.createSocket(socket, remoteAddress.getHostName(), socket.getPort(), true)); sslSocket.setUseClientMode(false); if (SSLContextService.ClientAuth.REQUIRED.toString().equals(clientAuth)) { this.setRequireTLS(true); sslSocket.setNeedClientAuth(true); } return sslSocket; } }; if (sslContextService != null) { smtpServer.setEnableTLS(true); } else { smtpServer.setHideTLS(true); } smtpServer.setSoftwareName("Apache NiFi SMTP"); smtpServer.setPort(port); smtpServer.setMaxConnections(context.getProperty(SMTP_MAXIMUM_CONNECTIONS).asInteger()); smtpServer.setMaxMessageSize(maxMessageSize); smtpServer.setConnectionTimeout(context.getProperty(SMTP_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue()); if (context.getProperty(SMTP_HOSTNAME).isSet()) { smtpServer.setHostName(context.getProperty(SMTP_HOSTNAME).getValue()); } return smtpServer; }
Example 10
Source File: ListenSMTP.java From nifi with Apache License 2.0 | 4 votes |
private SMTPServer prepareServer(final ProcessContext context, final ProcessSessionFactory sessionFactory) { final int port = context.getProperty(SMTP_PORT).asInteger(); final String host = context.getProperty(SMTP_HOSTNAME).getValue(); final ComponentLog log = getLogger(); final int maxMessageSize = context.getProperty(SMTP_MAXIMUM_MSG_SIZE).asDataSize(DataUnit.B).intValue(); //create message handler factory final MessageHandlerFactory messageHandlerFactory = (final MessageContext mc) -> { return new SmtpConsumer(mc, sessionFactory, port, host, log, maxMessageSize); }; //create smtp server final SSLContextService sslContextService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class); final SMTPServer smtpServer = sslContextService == null ? new SMTPServer(messageHandlerFactory) : new SMTPServer(messageHandlerFactory) { @Override public SSLSocket createSSLSocket(Socket socket) throws IOException { InetSocketAddress remoteAddress = (InetSocketAddress) socket.getRemoteSocketAddress(); String clientAuth = context.getProperty(CLIENT_AUTH).getValue(); SSLContext sslContext = sslContextService.createSSLContext(SslContextFactory.ClientAuth.valueOf(clientAuth)); SSLSocketFactory socketFactory = sslContext.getSocketFactory(); SSLSocket sslSocket = (SSLSocket) (socketFactory.createSocket(socket, remoteAddress.getHostName(), socket.getPort(), true)); sslSocket.setUseClientMode(false); if (SslContextFactory.ClientAuth.REQUIRED.toString().equals(clientAuth)) { this.setRequireTLS(true); sslSocket.setNeedClientAuth(true); } return sslSocket; } }; if (sslContextService != null) { smtpServer.setEnableTLS(true); } else { smtpServer.setHideTLS(true); } smtpServer.setSoftwareName("Apache NiFi SMTP"); smtpServer.setPort(port); smtpServer.setMaxConnections(context.getProperty(SMTP_MAXIMUM_CONNECTIONS).asInteger()); smtpServer.setMaxMessageSize(maxMessageSize); smtpServer.setConnectionTimeout(context.getProperty(SMTP_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue()); if (context.getProperty(SMTP_HOSTNAME).isSet()) { smtpServer.setHostName(context.getProperty(SMTP_HOSTNAME).getValue()); } return smtpServer; }