com.lightningkite.lightningserver.email.SmtpTest.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of server-core Show documentation
Show all versions of server-core Show documentation
A set of tools to fill in/replace what Ktor is lacking in.
The newest version!
package com.lightningkite.lightningserver.email
import com.lightningkite.lightningserver.serialization.Serialization
import kotlinx.coroutines.runBlocking
import kotlinx.serialization.decodeFromString
import org.junit.Test
import java.io.File
class SmtpTest {
@Test
fun testSmtp() {
val credentials = File("local/test-smtp.json")
if (!credentials.exists()) {
println("No credentials to test with at ${credentials.absolutePath}")
return
}
val client = SmtpEmailClient(credentials.readText().let { Serialization.json.decodeFromString(credentials.readText()) })
runBlocking {
client.send(Email(
subject = "Subject 2", fromLabel = "Joseph Ivie", fromEmail = "[email protected]",
to = listOf(EmailLabeledValue("[email protected]", "Joseph Ivie")),
html = "Hello world!
",
))
}
}
}