Create and manage real email addresses in Java, Kotlin and more using the free MailSlurp SDK.

Why Java?

Java and it's related JVM cousins provide a wonderful programming experience. SMTP servers on the other hand do not! That's why we made MailSlurp: as Java and Kotlin developers ourselves we wanted a better way to send and receive emails in JUnit tests.

To skip right to the code see the Java Method Documentation or JavaDocs.

Install

MailSlurp has a simple REST API for creating email addresses. These inboxes can then be used to send and receive emails and attachments without the need for a MailServer.

An official Java SDK is available on Maven Central for free with an MIT license. You can use Maven, SBT, Gradle or any build agent you wish.

Maven import

To use MailSlurp with maven add the dependencies to your project:

Gradle import

To setup MailSlurp with Gradle simple include the following:

Create a client

To start using the MailSlurp API you need a free API Key. Get one by signing up.

Then import and configure the SDK like so:

Listing inboxes

You can list your email addresses in a paginated format:

Something more complicated

Now that we know how to get started let's try something more complicated. We can create two email addresses and send an email with an attachment between them. Then we can wait for the email to arrive then download the sent attachment. This can be useful in many test environments.

Next steps

Sending and receive emails in Java, Kotlin, Groovy, Scala, Clojure and more is easy with MailSlurp. It is free for personal use and is built on top of scalable cloud infrastructure. To get started see the Java examples page or the official developer docs.