./mvnw clean install -Pdocker-Pdockerincludes Docker image build (optional, omit to skip)- Requires JDK 11+ and Maven 3.9.x
- Default goal is
install
# All tests (unit + integration)
./mvnw clean verify
# Skip integration tests for faster feedback
./mvnw clean verify -DskipITs
# Run a specific test class
./mvnw test -Dtest=ImapServerTest
# Run a specific test method
./mvnw test -Dtest=ImapServerTest#testRetrieveSimple
# Run integration tests only
./mvnw verify -DskipTestsmvn site -Psite- Checkstyle is configured and runs during builds
- PMD and FindBugs plugins are available in pom.xml
- Javadoc generation is part of the build
GreenMail is a virtual mail server for testing SMTP, IMAP, and POP3 protocols. It's structured as a multi-module Maven project:
- greenmail-core: Main mail server implementation with protocol handlers (SMTP/IMAP/POP3), user management, mail storage
- greenmail-junit4/junit5: Test framework integration (GreenMailRule for JUnit4, extensions for JUnit5)
- greenmail-spring: Spring Framework integration
- greenmail-standalone: Runnable standalone server
- greenmail-webapp: Web UI for managing the server
smtp/,imap/,pop3/: Protocol-specific implementationsstore/: Mail storage and retrievaluser/: User and mailbox managementconfiguration/: Server setup and configurationutil/: Utilities including GreenMailUtil and Retriever for common operations
- 2.1.x: Jakarta EE 10 (JakartaMail 2.1.x), Java 11+
- 2.0.x: Jakarta EE 9 (JakartaMail 2.0.x), Java 11+
- 1.6.x: Jakarta EE 8 (JakartaMail 1.6.x), Java 8+
- Unit tests: Named
*Test.javainsrc/test/java - Integration tests: Named
*IT.javainsrc/test/java - Test fixture: Use
GreenMailRule(JUnit4) orGreenMailExtension(JUnit5) - Assertions: Use AssertJ (
assertThat()) for readable assertions - Common setup:
ServerSetupTestprovides pre-configured server setups (SMTP, IMAPS, IMAP, POP3, etc.)
Example (JUnit4):
@Rule
public final GreenMailRule greenMail = new GreenMailRule(
new ServerSetup[]{ServerSetupTest.SMTP, ServerSetupTest.IMAP}
);
@Test
public void testSendAndRetrieve() throws Exception {
GreenMailUtil.sendTextEmail("to@test.com", "from@test.com",
"subject", "body", greenMail.getSmtp());
// assertions...
}Each protocol handler follows a consistent pattern:
commands/: Protocol command implementationscommands/parser/: Command parsing logic- Protocol state management and protocol handler implementations
Use Jakarta EE imports (not javax.*):
jakarta.mail.*jakarta.activation.*- Angus Mail implementation:
org.eclipse.angus.mail.*
- Properties-based configuration via
PropertiesBasedGreenMailConfigurationBuilder - GreenMailRule handles server startup/teardown
- ServerSetup objects define protocol + port combinations
Before implementing changes, review CONTRIBUTING.md:
- Keep patches focused: Avoid mixing unrelated changes
- Include tests: Every bug fix or feature should include a test case
- Minimize dependencies: GreenMail prioritizes being lightweight
- Backward compatibility: Be aware that changes may affect multiple versions/branches
- Avoid cosmetic changes: Refactoring and reformatting alone won't be accepted without prior discussion
- Branches: Active branches are
master(2.1),releases/2.0.x, andreleases/1.6.x
The CI pipeline in .github/workflows/ci.yml:
- Runs on Java 11, 17, and 21
- Builds with Docker profile enabled
- Runs on push to master, release branches, and all PRs
- Uses Maven caching for faster builds