Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mailslurp/mailslurp-client-kotlin
Kotlin Email Library for MailSlurp
https://github.com/mailslurp/mailslurp-client-kotlin
Last synced: 19 days ago
JSON representation
Kotlin Email Library for MailSlurp
- Host: GitHub
- URL: https://github.com/mailslurp/mailslurp-client-kotlin
- Owner: mailslurp
- License: mit
- Created: 2021-04-04T01:26:53.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-09-17T09:24:45.000Z (over 2 years ago)
- Last Synced: 2024-11-08T17:11:57.325Z (2 months ago)
- Language: Kotlin
- Size: 15 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Kotlin Email Library
Official MailSlurp client for Kotlin. Create email accounts with real email addresses. Send and receive emails and attachments from Kotlin tests and code.
> WARNING: Please use the Java version instead [mailslurp-client-java](https://search.maven.org/artifact/com.mailslurp/mailslurp-client-java) as the Kotlin library cannot handle API methods that return generic lists at this stage.
## Quick links
- [Maven Central package](https://search.maven.org/artifact/com.mailslurp/mailslurp-client-kotlin)
- [Source code](https://github.com/mailslurp/mailslurp-client-kotlin)
- [Method Reference](https://docs.mailslurp.com/kotlin/docs/)
- [Documentation](https://docs.mailslurp.com/kotlin/docs/)## Install
The MailSlurp Kotlin package is [hosted on Maven Central](https://search.maven.org/artifact/com.mailslurp/mailslurp-client-kotlin).
### Maven
```xml
com.mailslurp
mailslurp-client-kotlin
${version}```
### Gradle
```groovy
implementation 'com.mailslurp:mailslurp-client-kotlin:version'
```## Configure
MailSlurp for Kotlin provides API controllers that match the REST API for MailSlurp. Each controller must be provided with an API key. [Create a free MailSlurp account](https://app.mailslurp.com/sign-up/) to obtain an API key.
```kotlin
val apiKey: String = System.getenv("API_KEY")
val inboxController = InboxControllerApi(apiKey)
```## Example
```kotlin
package com.mailslurp.examplesimport com.mailslurp.apis.InboxControllerApi
import com.mailslurp.apis.WaitForControllerApi
import com.mailslurp.models.SendEmailOptions
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import kotlin.test.assertEquals
import kotlin.test.assertTrue@RunWith(JUnit4::class)
class MailSlurpKotlinTest {private val apiKey: String by lazy { System.getenv("API_KEY") }
@Test
fun `can create inboxes`() {
val inboxController = InboxControllerApi(apiKey)
val inbox = inboxController.createInbox(null, null, null, null, null, null, null, null, null)
assertTrue(inbox.emailAddress?.contains("@mailslurp") ?: false)
}@Test
fun `can send and receive email`() {
// create inbox
val inboxController = InboxControllerApi(apiKey)
val waitForController = WaitForControllerApi(apiKey)
val inbox = inboxController.createInbox(null, null, null, null, null, null, null, null, null)val testSubject = "test-subject"
val confirmation = inboxController.sendEmailAndConfirm(
inboxId = inbox.id!!,
sendEmailOptions = SendEmailOptions(
to = listOf(inbox.emailAddress!!),
subject = testSubject
)
)
assertEquals(confirmation.inboxId, inbox.id)val email = waitForController.waitForLatestEmail(
inboxId = inbox.id!!,
timeout = 60_000,
unreadOnly = true
)
assertTrue(email.subject == "test-subject")
}
}
```