Java email client: send and receive emails and attachments in Java, Kotlin and more

MailSlurp Java SDK for sending and receive email and attachments on the JVM.

java email read

Create email addresses in Java using MailSlurp's official JVM SDK. Send and receive emails and attachments in Java, Kotlin, Groovy, Clojure and other JVM languages. MailSlurp lets you use real email in code and tests without need for SMTP mail servers.Fo

For docs see the JavaDoc website.


You can install MailSlurp's email library from maven central.

Gradle build file

dependencies {

Maven pom file

<!-- place inside the <dependencies> block -->

Example usage

A basic usage of MailSlurp is to create a disposable test email account for testing. First configure your client with an API key that you can obtain from the MailSlurp dashboard.

Configure client

Import the MailSlurp package and configure the API key.

import com.mailslurp.apis.*;
import com.mailslurp.clients.*;
import com.mailslurp.models.*;

// create a MailSlurp client with your API_KEY
ApiClient defaultClient = Configuration.getDefaultApiClient();

Create an email account in Java

Use the inbox controller to create new inboxes:

// create an inbox using the inbox controller
InboxControllerApi inboxControllerApi = new InboxControllerApi(defaultClient);
Inbox inbox = inboxControllerApi.createInbox(null, null, null, null, null, null, null);

// verify inbox
assertEquals(inbox.getEmailAddress().contains(""), true);

Get started