public Account allocateAccount() throws Exception {
if (unallocatedAccounts.isEmpty()) {
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 {