package org.keycloak.testsuite;

import com.icegreen.greenmail.util.GreenMail;
import com.icegreen.greenmail.util.ServerSetup;

import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMessage.RecipientType;

public class MailServer {

    public static void main(String[] args) throws Exception {
        ServerSetup setup = new ServerSetup(3025, "localhost", "smtp");

        GreenMail greenMail = new GreenMail(setup);
        greenMail.start();

        System.out.println("Started mail server (localhost:3025)");
        System.out.println();
        
        while (true) {
            int c = greenMail.getReceivedMessages().length;

            if (greenMail.waitForIncomingEmail(Long.MAX_VALUE, c + 1)) {
                MimeMessage message = greenMail.getReceivedMessages()[c++];
                System.out.println("Received mail to " + message.getRecipients(RecipientType.TO)[0]);
                System.out.println();
                System.out.println(message.getContent());
                System.out.println("-------------------------------------------------------");
            }
        }
    }

}

@@ -214,16 +214,58 @@
 entType;
+%0Aimport javax.mail.internet.MimeMultipart;
 %0A%0Apublic
@@ -840,16 +840,111 @@
 )%5Bc++%5D;%0A
+                System.out.println(%22-------------------------------------------------------%22);%0A
         
@@ -1053,38 +1053,605 @@
         
-System.out.println();%0A
+if (message.getContent() instanceof MimeMultipart) %7B%0A                    MimeMultipart mimeMultipart = (MimeMultipart) message.getContent();%0A                    for (int i = 0; i %3C mimeMultipart.getCount(); i++) %7B%0A                        System.out.println(%22----%22);%0A                        System.out.println(mimeMultipart.getBodyPart(i).getContentType() + %22:%22);%0A                        System.out.println();%0A                        System.out.println(mimeMultipart.getBodyPart(i).getContent());%0A                    %7D%0A                %7D else %7B%0A                    System.out.println();%0A    
         
@@ -1692,32 +1692,50 @@
 .getContent());%0A
+                %7D%0A
                 

Add support for multi-part to MailServer util