agentmail4k -- AgentMail Kotlin DSL
An idiomatic Kotlin DSL for the AgentMail API, built on Ktor and kotlinx.serialization.
Features
- DSL-driven API — fluent Kotlin builders for every operation
- Coroutine-native — all API calls are
suspendfunctions - Scoped access — work within an inbox or pod context
- Workflows — built-in polling, auto-reply, bulk operations, and webhook handling
- Type-safe — kotlinx.serialization models with full type safety
Installation
Gradle (Kotlin DSL)
dependencies {
implementation("com.agentmail4k:agentmail4k:0.1.3")
}
Gradle (Groovy)
dependencies {
implementation 'com.agentmail4k:agentmail4k:0.1.3'
}
Quick Start
suspend fun quickStart() {
val client = AgentMailClient()
// Create an inbox
val inbox = client.createInbox("support", "example.com", "Support Team")
println("Created inbox: ${inbox.email}")
// Send a message
val response = client.sendMessage {
from = inbox.inboxId
to = listOf("user@example.com")
subject = "Hello from AgentMail!"
text = "This is a test message sent with agentmail4k."
}
println("Sent message: ${response!!.messageId}")
client.close()
}
Next Steps
- Getting Started — set up your API key and send your first message
- Configuration — customize timeouts, retries, and more
- Inboxes — create and manage inboxes