測試用的郵件服務器 GreenMail
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>
}
本文由用戶 fmms 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!