Email testing framework for gmail
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
  <title>GreenMail - Email Test Servers</title>
  <link rel="stylesheet" href="stylesheet.css" type="text/css" />

<div id="header">
<img src="pics/greenmail.gif" title="GreenMail - Testing SMTP, POP3, IMAP">
Latest Release GreenMail v1.3.1b - May 27th, 2009

<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="">Blog</a></span>
| <span class="page"><a href="">Download</a></span>
| <span class="page"><a href="feedback.html">Feedback</a></span>

<table width="100%">
<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.
GreenMail is the fist and only library that offers a test framework for both receiving and retrieving emails from Java. 
GreenMail is useful in the following scenarios:

<h3>Test Your Sending Code</h3>
<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>

<div class="codeSample"><pre>
public void testYourSendingCode() throws Exception {
    GreenMail greenMail = new GreenMail(); //uses test ports by default
    GreenMailUtil.sendTextEmailTest("", "", "subject", "body"); //replace this with your send code
    assertEquals("body", GreenMailUtil.getBody(greenMail.getReceivedMessages()[0]));
    //<b>That's it!</b>

<h3>Test Your Retrieving Code</h3>
<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"></a> class</li>

<div class="codeSample"><pre>
public void testYourRetrievingCode() throws Exception {
    GreenMail greenMail = new GreenMail(); //uses test ports by default
    MimeMessage message = <b>&lt;CONSTRUCT MESSAGE &gt;</b>
    User user = greenMail.setUser("", "login-id", "password");
    GreenMailUtil.sendTextEmailTest("", "", subject, body);
    assertEquals(<b>2</b>, greenMail.getReceivedMessages().length);

<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="">Apache James</a> or <a href="">JBoss Mail</a>).


The implementation is in 100% Java with only a few library dependencies:
  <li>javamail.jar - <a href="">JavaMail API</a></li>
  <li>activation.jar - <a href="">Java Activation Framework</a>, required by JavaMail</li>
  <li>slf4j-api.jar - required for logging via <a href="">Simple Logging Facade for Java</a></li>

<h2>Source Code</h2>
GreenMail is open source released under <a href="" rel="nofollow">The Apache 2.0 License</a>. 
Binaries and source can be downloaded <a href="">here on Sourceforge</a>.
GreenMail's protocol source code is based on a cocktail of <a href="" rel="nofollow">Foedus</a> and <a href="" rel="nofollow">James</a>.

<td class="gads">


<div class="footer">
Copyright &copy; 2009 <a href="">Icegreen Technologies</a>
<a href=""><img src="" width="88" height="32" border="0" alt="Support This Project" /> </a>
<a href=""><img src=";type=1" width="88" height="31" border="0" alt=" Logo" /></a>