GreenMail - 测试用的邮件服务器


未知
跨平台
Java

软件简介

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

示例代码

public void testYourSendingCode() throws Exception {  
    GreenMail greenMail = new GreenMail(); //uses test ports by default  
    greenMail.start();  
    GreenMailUtil.sendTextEmailTest("to@localhost.com", "from@localhost.com", "subject", "body"); //replace this with your send code  
    assertEquals("body", GreenMailUtil.getBody(greenMail.getReceivedMessages()[0]));  
    greenMail.stop();  
    // **That's it!**  
 }