use of org.subethamail.smtp.helper.SimpleMessageListenerAdapter in project vertx-examples by vert-x3.
the class LocalSmtpServer method startWithAuth.
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();
}
use of org.subethamail.smtp.helper.SimpleMessageListenerAdapter in project fake-smtp-server by gessnerfl.
the class SmtpServerFactoryImpl method create.
@Override
public SmtpServer create() {
SimpleMessageListenerAdapter simpleMessageListenerAdapter = new SimpleMessageListenerAdapter(emailPersister);
SMTPServer smtpServer = new SMTPServer(simpleMessageListenerAdapter);
configurator.configure(smtpServer);
return new SmtpServerImpl(smtpServer);
}
use of org.subethamail.smtp.helper.SimpleMessageListenerAdapter in project motech by motech.
the class EmailChannelBundleIT method testEmailSentOnSendEmailEvent.
@Test
public void testEmailSentOnSendEmailEvent() throws MessagingException, IOException, InterruptedException {
SMTPServer smtpServer = new SMTPServer(new SimpleMessageListenerAdapter(this));
new Wait(new ContextPublishedWaitCondition(bundleContext, "org.motechproject.motech-platform-event"), 5000).start();
new Wait(new ContextPublishedWaitCondition(bundleContext), 5000).start();
try {
smtpServer.setPort(8099);
smtpServer.start();
String messageText = "test message";
String from = "testfromaddress";
String to = "testtoaddress";
String subject = "test subject";
Map<String, Object> values = new HashMap<>();
values.put("fromAddress", from);
values.put("toAddress", to);
values.put("message", messageText);
values.put("subject", subject);
eventRelay.sendEventMessage(new MotechEvent(SendEmailConstants.SEND_EMAIL_SUBJECT, values));
new Wait(lock, this, 100, 60000).start();
assertTrue("Message not received", messageReceived);
assertNotNull(receivedMessageText);
assertEquals(messageText, receivedMessageText.trim());
} finally {
smtpServer.stop();
}
}
use of org.subethamail.smtp.helper.SimpleMessageListenerAdapter in project vertx-examples by vert-x3.
the class LocalSmtpServer method start.
public static void start(int port) {
SMTPServer smtpServer = new SMTPServer(new SimpleMessageListenerAdapter(new MyMessageListener()));
smtpServer.setPort(port);
smtpServer.start();
}
Aggregations