Newer
Older
marking / src / test / java / MailServer.java

import com.icegreen.greenmail.util.GreenMail;
import com.icegreen.greenmail.util.ServerSetupTest;
import jakarta.mail.MessagingException;
import jakarta.mail.internet.MimeMessage;

/**
 *
 * @author Mark George <mark.george@otago.ac.nz>
 */
public class MailServer {

	public static void main(String[] args) throws InterruptedException, MessagingException {

		GreenMail server = new GreenMail(ServerSetupTest.SMTP.port(2525));
		server.setUser("geoma48p", "testing123");
		server.start();

		System.out.println("READY");

		while (true) {
			MimeMessage[] receivedMessages = server.getReceivedMessages();
			for (MimeMessage receivedMessage : receivedMessages) {
				System.out.println(receivedMessage.getSubject());
			}
			server.reset();
			Thread.sleep(500);
		}

	}

}