Greenmail maven plugin

The GreenMail Maven plugin!

GreenMail is a popular open-source tool for testing email-based applications. The GreenMail Maven plugin is a plugin that integrates GreenMail with the Maven build tool, allowing you to easily run GreenMail tests as part of your Maven build process.

Here are some key features of the GreenMail Maven plugin:

  1. Easy integration: The plugin provides a simple way to integrate GreenMail with your Maven project, allowing you to run GreenMail tests as part of your build process.
  2. Configurable: You can configure the plugin to customize the behavior of GreenMail, such as setting the email server, port, and other settings.
  3. Support for multiple email protocols: GreenMail supports multiple email protocols, including SMTP, POP3, and IMAP.
  4. Support for multiple test modes: The plugin provides several test modes, including:
    • SMTP: Send emails and verify that they are received by the email server.
    • POP3: Retrieve emails from the email server and verify their contents.
    • IMAP: Retrieve emails from the email server and verify their contents.
  5. Support for test data: The plugin allows you to specify test data, such as email addresses, subjects, and bodies, to use in your tests.
  6. Integration with Maven Surefire: The plugin integrates with Maven Surefire, allowing you to run GreenMail tests as part of your Maven build process.

To use the GreenMail Maven plugin, you'll need to add the following dependencies to your pom.xml file:

<dependencies>
    <dependency>
        <groupId>com.icegreen</groupId>
        <artifactId>greenmail</artifactId>
        <version>1.6.6</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.icegreen</groupId>
        <artifactId>greenmail-maven-plugin</artifactId>
        <version>1.6.6</version>
        <scope>test</scope>
    </dependency>
</dependencies>

You'll also need to configure the plugin in your pom.xml file:

<build>
    <plugins>
        <plugin>
            <groupId>com.icegreen</groupId>
            <artifactId>greenmail-maven-plugin</artifactId>
            <version>1.6.6</version>
            <executions>
                <execution>
                    <goals>
                        <goal>start</goal>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <server>smtp.gmail.com</server>
                <port>587</port>
                <username>your-email-username</username>
                <password>your-email-password</password>
            </configuration>
        </plugin>
    </plugins>
</build>

In this example, we're configuring the plugin to use an SMTP server, port 587, and specifying the email username and password.

Once you've configured the plugin, you can run your GreenMail tests as part of your Maven build process by executing the mvn test command. The plugin will start the GreenMail server, run your tests, and then stop the server.