Usage

The following examples describe the basic usage of the e-Mail Server Maven Plugin.

Basic Configuration

The recommended basic configuration is as follows.

<project>
  ...  
  <build>
    <pluginManagement>
      <plugins>
        ...
        <plugin>
          <groupId>com.btmatthews.maven.plugins</groupId>
          <artifactId>emailserver-maven-plugin</artifactId>
          <version>1.1.1</version>
        </plugin>
    </pluginManagement>
    <plugins>
      ...
      <plugin>
        <groupId>com.btmatthews.maven.plugins</groupId>
        <artifactId>emailserver-maven-plugin</artifactId>
        <configuration>
          <monitorPort>[port number]</monitorPort>
          <monitorKey>[stop key]</monitorKey>
        </configuration>
        <executions>
          <execution>
            <id>start-mail</id>
            <goals>
              <goal>run</goal>
            <goals>
            <configuration>
              <daemon>true</daemon>
            </configuration>
          </execution>
          <execution>
            <id>stop-mail</id>
            <goals>
              <goal>stop</goal>
            <goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

Example

The following example shows the configuration that could be used to launch GreenMail to run integration tests and then to shut it down afterwards.

<project>
  ...
  <build>
    ...
    <plugins>
      ...
      <plugin>
        <groupId>com.btmatthews.maven.plugins</groupId>
        <artifactId>emailserver-maven-plugin</artifactId>
        <configuration>
          <monitorPort>10025</monitorPort>
          <monitorKey>greenmail</monitorKey>
        </configuration>
        <executions>
          <execution>
            <id>start-mail</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <daemon>true</daemon>
              <portOffset>3000</portOffset>
              <useSSL>false</useSSL>
              <serverName>greenmail</serverName>
            </configuration>
          </execution>
          <execution>
            <id>stop-mail</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>stop</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>