String login = "test" + accountNumber++;
GreenMailUser user = greenMail.setUser(login + "@localhost", login, "password");
final MailFolder inbox = greenMail.getManagers().getImapHostManager().getInbox(user);
inbox.addListener(new FolderListener() {
public void added(int msn) {
StoredMessage storedMessage = (StoredMessage)inbox.getMessages().get(msn-1);
try {
OutputStream out = logManager.createLog("greenmail");
try {
storedMessage.getMimeMessage().writeTo(out);
} finally {
out.close();
}
} catch (Exception ex) {
ex.printStackTrace();