本文整理汇总了Java中org.subethamail.smtp.server.SMTPServer类的典型用法代码示例。如果您正苦于以下问题:Java SMTPServer类的具体用法?Java SMTPServer怎么用?Java SMTPServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SMTPServer类属于org.subethamail.smtp.server包,在下文中一共展示了SMTPServer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startup
import org.subethamail.smtp.server.SMTPServer; //导入依赖的package包/类
@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());
}
示例2: shouldConfigureAuthenticationWhenAuthenticationIsConfiguredProperly
import org.subethamail.smtp.server.SMTPServer; //导入依赖的package包/类
@Test
public void shouldConfigureAuthenticationWhenAuthenticationIsConfiguredProperly(){
final String username = "username";
final String password = "password";
final FakeSmtpConfigurationProperties.Authentication authentication = mock(FakeSmtpConfigurationProperties.Authentication.class);
when(authentication.getUsername()).thenReturn(username);
when(authentication.getPassword()).thenReturn(password);
when(fakeSmtpConfigurationProperties.getAuthentication()).thenReturn(authentication);
final SMTPServer smtpServer = mock(SMTPServer.class);
sut.configure(smtpServer);
ArgumentCaptor<AuthenticationHandlerFactory> argumentCaptor = ArgumentCaptor.forClass(AuthenticationHandlerFactory.class);
verify(smtpServer).setAuthenticationHandlerFactory(argumentCaptor.capture());
AuthenticationHandlerFactory authenticationHandlerFactory = argumentCaptor.getValue();
assertNotNull(authenticationHandlerFactory);
assertThat(authenticationHandlerFactory, instanceOf(EasyAuthenticationHandlerFactory.class));
EasyAuthenticationHandlerFactory easyAuthenticationHandlerFactory = (EasyAuthenticationHandlerFactory)authenticationHandlerFactory;
assertSame(basicUsernamePasswordValidator, easyAuthenticationHandlerFactory.getValidator());
}
示例3: start
import org.subethamail.smtp.server.SMTPServer; //导入依赖的package包/类
public static StartResult start(int port) {
try {
smtpServer = new SMTPServer(new SimpleMessageListenerAdapter(listener), new SMTPAuthHandlerFactory());
smtpServer.setPort(port);
smtpServer.start();
return new StartResult(true, null);
} catch (Throwable e) {
log.error("Failed to start SMTP server", e);
if (e.getCause() instanceof BindException) {
return new StartResult(false, String.format(Messages.get("%s, port: %s"), e.getCause().getMessage(), port));
} else if (e.getCause() instanceof IllegalArgumentException && e.getMessage().contains("out of range")) {
return new StartResult(false, String.format(Messages.get("server.error.outofrange"), port));
} else {
return new StartResult(false, e.getLocalizedMessage());
}
}
}
示例4: start
import org.subethamail.smtp.server.SMTPServer; //导入依赖的package包/类
/**
*/
@PostConstruct
public void start() throws IOException
{
if (this.smtpServer != null)
throw new IllegalStateException("SMTPServer already running");
log.log(Level.INFO,"Starting SMTP service: {0}:{1}", new Object[]{(this.bindAddress==null ? "*" : this.bindAddress), this.port});
this.smtpServer = new SMTPServer(new SMTPHandler(this));
this.smtpServer.setHideTLS(true);
InetAddress binding = this.getBinding();
if (binding != null)
this.smtpServer.setBindAddress(binding);
this.smtpServer.setPort(this.port);
if (this.hostName != null)
this.smtpServer.setHostName(this.hostName);
this.smtpServer.start();
}
示例5: init
import org.subethamail.smtp.server.SMTPServer; //导入依赖的package包/类
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(timeService, "TimeService 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();
}
}
示例6: start
import org.subethamail.smtp.server.SMTPServer; //导入依赖的package包/类
@PostConstruct
public void start() {
smtpServer = new SMTPServer(myMessageHandlerFactory);
smtpServer.setPort(port);
smtpServer.setHostName(hostName);
smtpServer.start();
log.info("****** SMTP Server is running for domain " + smtpServer.getHostName()
+ " on port " + smtpServer.getPort());
}
示例7: configure
import org.subethamail.smtp.server.SMTPServer; //导入依赖的package包/类
public void configure(SMTPServer smtpServer) {
smtpServer.setPort(fakeSmtpConfigurationProperties.getPort());
smtpServer.setBindAddress(fakeSmtpConfigurationProperties.getBindAddress());
if (fakeSmtpConfigurationProperties.getAuthentication() != null) {
configureAuthentication(smtpServer, fakeSmtpConfigurationProperties.getAuthentication());
}
}
示例8: configureAuthentication
import org.subethamail.smtp.server.SMTPServer; //导入依赖的package包/类
private void configureAuthentication(SMTPServer smtpServer, FakeSmtpConfigurationProperties.Authentication authentication) {
if (StringUtils.isEmpty(authentication.getUsername())) {
logger.error("Username is missing; skip configuration of authentication");
} else if (StringUtils.isEmpty(authentication.getPassword())) {
logger.error("Password is missing; skip configuration of authentication");
} else {
logger.info("Setup simple username and password authentication for SMTP server");
smtpServer.setAuthenticationHandlerFactory(new EasyAuthenticationHandlerFactory(basicUsernamePasswordValidator));
}
}
示例9: create
import org.subethamail.smtp.server.SMTPServer; //导入依赖的package包/类
@Override
public SmtpServer create() {
SimpleMessageListenerAdapter simpleMessageListenerAdapter = new SimpleMessageListenerAdapter(emailPersister);
SMTPServer smtpServer = new SMTPServer(simpleMessageListenerAdapter);
configurator.configure(smtpServer);
return new SmtpServerImpl(smtpServer);
}
示例10: shouldConfigureBasicParameters
import org.subethamail.smtp.server.SMTPServer; //导入依赖的package包/类
@Test
public void shouldConfigureBasicParameters(){
final Integer port = 1234;
final InetAddress bindingAddress = mock(InetAddress.class);
when(fakeSmtpConfigurationProperties.getPort()).thenReturn(port);
when(fakeSmtpConfigurationProperties.getBindAddress()).thenReturn(bindingAddress);
final SMTPServer smtpServer = mock(SMTPServer.class);
sut.configure(smtpServer);
verify(smtpServer).setPort(port);
verify(smtpServer).setBindAddress(bindingAddress);
verify(smtpServer, never()).setAuthenticationHandlerFactory(any(AuthenticationHandlerFactory.class));
}
示例11: shouldSkipConfigurationOfAuthenticationWhenUsernameIsNull
import org.subethamail.smtp.server.SMTPServer; //导入依赖的package包/类
@Test
public void shouldSkipConfigurationOfAuthenticationWhenUsernameIsNull(){
final String password = "password";
final FakeSmtpConfigurationProperties.Authentication authentication = mock(FakeSmtpConfigurationProperties.Authentication.class);
when(authentication.getUsername()).thenReturn(null);
when(authentication.getPassword()).thenReturn(password);
when(fakeSmtpConfigurationProperties.getAuthentication()).thenReturn(authentication);
final SMTPServer smtpServer = mock(SMTPServer.class);
sut.configure(smtpServer);
verify(smtpServer, never()).setAuthenticationHandlerFactory(any(AuthenticationHandlerFactory.class));
verify(logger).error(startsWith("Username"));
}
示例12: shouldSkipConfigurationOfAuthenticationWhenUsernameIsEmptyString
import org.subethamail.smtp.server.SMTPServer; //导入依赖的package包/类
@Test
public void shouldSkipConfigurationOfAuthenticationWhenUsernameIsEmptyString(){
final String password = "password";
final FakeSmtpConfigurationProperties.Authentication authentication = mock(FakeSmtpConfigurationProperties.Authentication.class);
when(authentication.getUsername()).thenReturn("");
when(authentication.getPassword()).thenReturn(password);
when(fakeSmtpConfigurationProperties.getAuthentication()).thenReturn(authentication);
final SMTPServer smtpServer = mock(SMTPServer.class);
sut.configure(smtpServer);
verify(smtpServer, never()).setAuthenticationHandlerFactory(any(AuthenticationHandlerFactory.class));
verify(logger).error(startsWith("Username"));
}
示例13: shouldSkipConfigurationOfAuthenticationWhenPasswordIsNull
import org.subethamail.smtp.server.SMTPServer; //导入依赖的package包/类
@Test
public void shouldSkipConfigurationOfAuthenticationWhenPasswordIsNull(){
final String username = "username";
final FakeSmtpConfigurationProperties.Authentication authentication = mock(FakeSmtpConfigurationProperties.Authentication.class);
when(authentication.getUsername()).thenReturn(username);
when(authentication.getPassword()).thenReturn(null);
when(fakeSmtpConfigurationProperties.getAuthentication()).thenReturn(authentication);
final SMTPServer smtpServer = mock(SMTPServer.class);
sut.configure(smtpServer);
verify(smtpServer, never()).setAuthenticationHandlerFactory(any(AuthenticationHandlerFactory.class));
verify(logger).error(startsWith("Password"));
}
示例14: shouldSkipConfigurationOfAuthenticationWhenPasswordIsEmptyString
import org.subethamail.smtp.server.SMTPServer; //导入依赖的package包/类
@Test
public void shouldSkipConfigurationOfAuthenticationWhenPasswordIsEmptyString(){
final String username = "username";
final FakeSmtpConfigurationProperties.Authentication authentication = mock(FakeSmtpConfigurationProperties.Authentication.class);
when(authentication.getUsername()).thenReturn(username);
when(authentication.getPassword()).thenReturn("");
when(fakeSmtpConfigurationProperties.getAuthentication()).thenReturn(authentication);
final SMTPServer smtpServer = mock(SMTPServer.class);
sut.configure(smtpServer);
verify(smtpServer, never()).setAuthenticationHandlerFactory(any(AuthenticationHandlerFactory.class));
verify(logger).error(startsWith("Password"));
}
示例15: shouldCreateNewInstanceAndDelegateCallsToRealImplementation
import org.subethamail.smtp.server.SMTPServer; //导入依赖的package包/类
@Test
public void shouldCreateNewInstanceAndDelegateCallsToRealImplementation(){
SMTPServer delegate = mock(SMTPServer.class);
SmtpServerImpl sut = new SmtpServerImpl(delegate);
sut.start();
verify(delegate).start();
sut.stop();
verify(delegate).stop();
}