Skip to content
forked from kirviq/dumbster

Dumbster - a simple fake SMTP server for unit testing

License

Notifications You must be signed in to change notification settings

perNyfelt/dumbster

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dumbster

The Dumbster is a very simple fake SMTP server designed for unit and system testing applications that send email messages. It responds to all standard SMTP commands but does not deliver messages to the user. The messages are stored within the Dumbster for later extraction and verification.

This repository is a fork of https://github.com/kirviq/dumbster.

Differences:

  1. Added a possibility to attach a listener on messages arriving
  2. Add support for multipart messages (patch created by koke24)
  3. Remove lombok
  4. Make SmtpMessage Json serializable and deserializable

Aside from that, the actual smtp logic is completely unchanged.

Usage

Add maven dependency:

<dependency>
    <groupId>se.alipsa</groupId>
    <artifactId>dumbster</artifactId>
    <version>1.7.2</version>
    <scope>test</scope>
</dependency>

Start testing:

class SomeTest {
    public void runTest() {
        try (SimpleSmtpServer dumbster = SimpleSmtpServer.start(SimpleSmtpServer.AUTO_SMTP_PORT)) {
        
            sendMessage(dumbster.getPort(), "[email protected]", "Test", "Test Body", "[email protected]");
            
            List<SmtpMessage> emails = dumbster.getReceivedEmails();
            assertThat(emails, hasSize(1));
            SmtpMessage email = emails.get(0);
            assertThat(email.getHeaderValue("Subject"), is("Test"));
            assertThat(email.getBody(), is("Test Body"));
            assertThat(email.getHeaderValue("To"), is("[email protected]"));
        }
    }
}

See more examples in the included unit tests.

About

Dumbster - a simple fake SMTP server for unit testing

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Java 100.0%