use of com.icegreen.greenmail.smtp.SmtpServer in project concord by walmartlabs.
the class SmtpTaskTest method test.
@Test
public void test() throws Exception {
SmtpServer server = mail.getSmtp();
SmtpTask t = new SmtpTask();
t.send("localhost", server.getPort(), "my@mail.com", "their@mail.com", "test", "Hello!", "another@mail.com");
MimeMessage[] messages = mail.getReceivedMessages();
assertEquals(2, messages.length);
assertEquals("Hello!\r\n", messages[0].getContent());
mail.reset();
}
use of com.icegreen.greenmail.smtp.SmtpServer in project syndesis by syndesisio.
the class EMailTestServer method getEmailsInFolder.
public List<EMailMessageModel> getEmailsInFolder(String user, String password, String folderName) throws Exception {
if (server instanceof SmtpServer) {
throw new Exception("SMTP not applicable for reading folders");
}
Store store = server.createStore();
store.connect(user, password);
Folder newFolder = store.getFolder(folderName);
if (!newFolder.exists()) {
throw new Exception("No folder with name " + folderName);
}
newFolder.open(Folder.READ_ONLY);
List<EMailMessageModel> models = new ArrayList<>();
for (Message msg : newFolder.getMessages()) {
models.add(createMessageModel(msg));
}
return models;
}
Aggregations