Allow/Block Lists
Lists let you control which senders, recipients, domains, or subjects are allowed or blocked.
List Direction and Type
Every list operation requires a ListDirection and ListType:
- Direction:
ALLOWorBLOCK - Type:
SENDER,RECIPIENT,DOMAIN, orSUBJECT
Block a Sender
suspend fun blockSenderExample() {
val client = AgentMailClient()
val entry = client.createListEntry(ListDirection.BLOCK, ListType.SENDER) {
this.entry = "spammer@example.com"
}
println("Blocked: ${entry.entry}")
client.close()
}
Allow a Domain
suspend fun allowDomainExample() {
val client = AgentMailClient()
val entry = client.createListEntry(ListDirection.ALLOW, ListType.DOMAIN) {
this.entry = "trusted.com"
}
println("Allowed domain: ${entry.entry}")
client.close()
}
List Entries
suspend fun listEntriesExample() {
val client = AgentMailClient()
// List all blocked senders
val blocked = client.listEntries(ListDirection.BLOCK, ListType.SENDER) {
limit = 25
}
for (entry in blocked.entries) {
println("Blocked: ${entry.entry}")
}
// List all allowed domains
val allowed = client.listEntries(ListDirection.ALLOW, ListType.DOMAIN)
for (entry in allowed.entries) {
println("Allowed: ${entry.entry}")
}
client.close()
}
Get an Entry
suspend fun getEntryExample() {
val client = AgentMailClient()
val entry = client.getListEntry(ListDirection.BLOCK, ListType.SENDER, "spammer@example.com")
println("Entry: ${entry.entry}")
client.close()
}
Delete an Entry
suspend fun deleteEntryExample() {
val client = AgentMailClient()
client.deleteListEntry(ListDirection.BLOCK, ListType.SENDER, "spammer@example.com")
println("Entry removed from block list")
client.close()
}
Other List Types
Block by subject or recipient:
suspend fun listTypesExample() {
val client = AgentMailClient()
// Block by subject pattern
client.createListEntry(ListDirection.BLOCK, ListType.SUBJECT) {
entry = "Buy now"
}
// Block by recipient
client.createListEntry(ListDirection.BLOCK, ListType.RECIPIENT) {
entry = "no-reply@example.com"
}
client.close()
}
Next Steps
- Scoped Access — work with resources within an inbox or pod
- Metrics & Organization — view usage metrics and organization details
- Copy for Cursor / Claude — LLM-friendly cheat sheet for AI assistants