测试用的邮件服务器 GreenMail

fmms 13年前

GreenMail 是一组主要用来做测试用的邮件服务器,支持 SMTP、POP3、IMAP 等,可以用来嵌入到任何的 Java 程序中。

示例代码

public void testYourRetrievingCode() throws Exception {      GreenMail greenMail = new GreenMail(); //uses test ports by default      greenMail.start();            MimeMessage message = <CONSTRUCT MESSAGE >      User user = greenMail.setUser("to@localhost.com", "login-id", "password");      user.deliver(message);      GreenMailUtil.sendTextEmailTest("to@localhost.com", "from@localhost.com", subject, body);      assertEquals(2, greenMail.getReceivedMessages().length);            <PLACE YOUR POP3/IMAP RETRIVE CODE HERE>  }

项目主页:http://www.open-open.com/lib/view/home/1330592732217