final MimeMessage mail = GreenMailUtil.createTextEmail(to, "from@localhost", "Subject", "msg", greenMail.getSmtp().getServerSetup());
final Date sentDate = new GregorianCalendar(2000, 1, 1, 0, 0, 0).getTime();
mail.setSentDate(sentDate);
GreenMailUtil.sendMimeMessage(mail);
greenMail.waitForIncomingEmail(5000, 1);
<BUG>retrieveAndCheck(new Retriever(greenMail.getPop3()), to, sentDate, false);
retrieveAndCheck(new Retriever(greenMail.getImap()), to, sentDate, true);
}
private void retrieveAndCheck(Retriever retriever, String to, Date sentDate, boolean checkReceivedDate)

throws MessagingException, IOException {
Message[] messages = retriever.getMessages(to);</BUG>
assertThat(messages.length, is(1));

final MimeMessage mail = GreenMailUtil.createTextEmail(to, "from@localhost", "Subject", "msg", greenMail.getSmtp().getServerSetup());
final Date sentDate = new GregorianCalendar(2000, 1, 1, 0, 0, 0).getTime();
mail.setSentDate(sentDate);
GreenMailUtil.sendMimeMessage(mail);
greenMail.waitForIncomingEmail(5000, 1);
retrieveAndCheck(greenMail.getPop3(), to, sentDate, false);
retrieveAndCheck(greenMail.getImap(), to, sentDate, true);
}
private void retrieveAndCheck(AbstractServer server, String to, Date sentDate, boolean checkReceivedDate)
throws MessagingException, IOException {
Retriever retriever = new Retriever(server);
try {
Message[] messages = retriever.getMessages(to);
assertThat(messages.length, is(1));
