<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>GreenMail - Email Test Servers</title> <link rel="stylesheet" href="stylesheet.css" type="text/css" /> </head> <body> <div id="header"> <img src="pics/greenmail.gif" title="GreenMail - Testing SMTP, POP3, IMAP"> Latest Release GreenMail v1.3.1b - May 27th, 2009 </div> <div class="pages"> <span class="page"><a href="readme.html">About</a></span> | <span class="page"><a href="examples.html">Examples</a></span> | <span class="page"><a href="faq.html">FAQ</a></span> | <span class="page"><a href="javadocs/index.html">Javadocs</a></span> | <span class="page"><a href="http://www.icegreen.com/articles">Blog</a></span> | <span class="page"><a href="http://sourceforge.net/project/showfiles.php?group_id=159695">Download</a></span> | <span class="page"><a href="feedback.html">Feedback</a></span> </div> <br> <table width="100%"> <tr><td> <h2>Easy to use</h2> GreenMail is an open source, intuitive and easy-to-use test suite of email servers for testing purposes. <br>Supports SMTP, POP3, IMAP with SSL socket support. GreenMail also provides a JBoss GreenMail Service. <p> GreenMail is the fist and only library that offers a test framework for both receiving and retrieving emails from Java. </p> <h2>Scenarios</h2> GreenMail is useful in the following scenarios: <h3>Test Your Sending Code</h3> <ul> <li>System testing an application. GreenMail responds like a regular SMTP server but does not deliver any email, which enables it to be used in real life applications and real test cases. Messages can easily be extracted, verified, and modified. Support for SMTPS (SSL) is enabled. </li> <li>GreenMail is an excellent choice for unit testing code that needs to send email with a succinct, efficient (non-polling) way to wait for messages to arrive, retrieve, verify, and modify messages. </li> <li>Note that retrieval of emails can be made with a simple java method or through a provided POP3, IMAP retriever helper class.</li> </ul> <div class="codeSample"><pre> 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(); //<b>That's it!</b> } </pre> </div> <h3>Test Your Retrieving Code</h3> <ul> <li>Again GreenMail can be used for system or unit testing an application needing to use POP3 or IMAP by responding like a standard compliant POP3 or IMAP server. Support for POP3S and IMAPS (SSL) is also enabled. </li> <li>Messages can be placed directly in users mailboxes or by using SMTP.</li> <li>GreenMail ships with helper classes for sending and retrieving. See the javadocs for the <a href="javadocs/com/icegreen/greenmail/util/Retriever.html">Retriever.java</a> class</li> </ul> <div class="codeSample"><pre> public void testYourRetrievingCode() throws Exception { GreenMail greenMail = new GreenMail(); //uses test ports by default greenMail.start(); MimeMessage message = <b><CONSTRUCT MESSAGE ></b> User user = greenMail.setUser("to@localhost.com", "login-id", "password"); user.deliver(message); GreenMailUtil.sendTextEmailTest("to@localhost.com", "from@localhost.com", subject, body); assertEquals(<b>2</b>, greenMail.getReceivedMessages().length); <b><PLACE YOUR POP3/IMAP RETRIVE CODE HERE></b> } </pre> </div> <h3>Sending and Retrieving</h3> GreenMail can easily be configured to use all or a combination of ports, protocols, and bind addresses. For example it’s possible to run GreenMail on SMTP, POP3, POP3S and IMAPS ports as easily as only SMTP. Many systems might already be running these servers or don’t allow non root users to open the default ports which is why GreenMail ships with a special configuration for testing. <h3>Mocking a mail server for your development environment</h3> GreenMail provides a <a href="jboss-service.html">JBoss GreenMail service</a> for mocking a mail server for development. It safes you the overhead of either installing a full productive server (like <a href="http://james.apache.org/">Apache James</a> or <a href="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossMailServer">JBoss Mail</a>). <h2>Implementation</h2> The implementation is in 100% Java with only a few library dependencies: <ul> <li>javamail.jar - <a href="http://java.sun.com/products/javamail/">JavaMail API</a></li> <li>activation.jar - <a href="http://java.sun.com/products/javabeans/jaf/index.jsp">Java Activation Framework</a>, required by JavaMail</li> <li>slf4j-api.jar - required for logging via <a href="http://www.slf4j.org/">Simple Logging Facade for Java</a></li> </ul> <br> <h2>Source Code</h2> GreenMail is open source released under <a href="http://www.apache.org/licenses/LICENSE-2.0.txt" rel="nofollow">The Apache 2.0 License</a>. Binaries and source can be downloaded <a href="">here on Sourceforge</a>. <p> GreenMail's protocol source code is based on a cocktail of <a href="http://foedus.sourceforge.net" rel="nofollow">Foedus</a> and <a href="http://james.apache.org" rel="nofollow">James</a>. </p> </td> <td class="gads"> </td> </tr> </table> <br> <br> <br> <div class="footer"> Copyright © 2009 <a href="http://www.icegreen.com">Icegreen Technologies</a> <br><br> <a href="http://sourceforge.net/donate/index.php?group_id=159695"><img src="http://images.sourceforge.net/images/project-support.jpg" width="88" height="32" border="0" alt="Support This Project" /> </a> <a href="http://sourceforge.net"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=159695&type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" /></a> </div> </body> </html>