You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package com.icegreen.greenmail.standalone;
import java.util.List;
import java.util.Properties;
import javax.mail.Message.RecipientType;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import com.icegreen.greenmail.imap.ImapHostManager;
import com.icegreen.greenmail.store.MailFolder;
import com.icegreen.greenmail.store.StoredMessage;
import com.icegreen.greenmail.user.GreenMailUser;
import com.icegreen.greenmail.user.UserManager;
import com.icegreen.greenmail.util.GreenMail;
public class Bug {
public static void main(String[] args) throws Exception {
System.setProperty("greenmail.setup.test.smtp", "true");
System.setProperty("greenmail.setup.test.pop3", "true");
System.setProperty("greenmail.setup.test.imap", "true");
System.setProperty("greenmail.auth.disabled", "false");
System.setProperty("greenmail.hostname", "127.0.0.1");
System.setProperty("greenmail.verbose", "true");
final Properties properties = System.getProperties();
GreenMailStandaloneRunner standalone = new GreenMailStandaloneRunner();
standalone.doRun(properties);
GreenMail gm = standalone.getGreenMail();
UserManager um = gm.getManagers().getUserManager();
ImapHostManager im = gm.getManagers().getImapHostManager();
GreenMailUser user = um.createUser("[email protected]", "blar", "b123");
MailFolder inbox = im.getInbox(user);
MailFolder otherfolder = im.createMailbox(user, "otherfolder");
MimeMessage m1 = createMessage(gm, "sub1", "[email protected]", "[email protected]", "blar to dest1");
MimeMessage m2 = createMessage(gm, "sub2", "[email protected]", "[email protected]", "foo to dest2");
System.out.println("Storing in inbox");
inbox.store(m1);
System.out.println("Storing in otherfolder");
otherfolder.store(m2);
um.deleteUser(user);
List<StoredMessage> messages = im.getAllMessages();
System.out.println("Total number of mails on server: " + messages.size());
System.exit(0);
}
public static MimeMessage createMessage(GreenMail gm, String subject, String from, String to, String body) {
MimeMessage mm = null;
try {
javax.mail.Session smtpSession = gm.getSmtp().createSession();
mm = new MimeMessage(smtpSession);
mm.setRecipients(RecipientType.TO, to);
mm.setSubject(subject);
mm.setFrom(from);
mm.setText(body);
} catch (MessagingException e) {
e.printStackTrace();
}
return mm;
}
}
prints
Total number of mails on server: 1
when it should be zero. Deleting a user only deletes their INBOX and ignores their other folders.
The user is deleted and the other folders are orphaned.
(Fixed it already, I'll prepare PR with test case next).
The text was updated successfully, but these errors were encountered:
Proof:
prints
when it should be zero. Deleting a user only deletes their INBOX and ignores their other folders.
The user is deleted and the other folders are orphaned.
(Fixed it already, I'll prepare PR with test case next).
The text was updated successfully, but these errors were encountered: