This library allows you to open the platforms email chooser.
It provides following main features:
- prefill the email subject
- prefill the email content
- attach files to the mail
| Module | android | iOS | Notes |
|---|---|---|---|
| library | ✅ | ✅ | This is a very small library that allows you to send feedback from an app without internet permission via email, either directly or via an unintrusive notification. |
| Dependency | Version |
|---|---|
| Kotlin | 2.4.0 |
| Jetbrains Compose | 1.11.1 |
| Jetbrains Compose Material3 | 1.9.0 |
Using Version Catalogs
Define the dependencies inside your libs.versions.toml file.
[versions]
kmpmail = "<LATEST-VERSION>"
[libraries]
kmpmail-library = { module = "io.github.mflisar.kmpmail:library", version.ref = "kmpmail" }And then use the definitions in your projects build.gradle.kts file like following:
implementation(libs.kmpmail.library)Direct Dependency Notation
Simply add the dependencies inside your build.gradle.kts file.
val kmpmail = "<LATEST-VERSION>"
implementation("io.github.mflisar.kmpmail:library:${kmpmail}")This library is used like following:
val mail = Mail(
receivers = listOf(receiver),
subject = "Feedback from $platform Demo App",
body = "Please write your feedback here...\n\n",
bodyIsHtml = false,
attachments = listOf(MailAttachmentFile(tempFile))
)
val success = mail.startEmailChooser("Select email app")This will start the email chooser of the platform. If it returns false, no email clients are installed or set up, so you could fallback to a mailto: solution or whatever you want.
A full demo is included inside the demo module, it shows nearly every usage with working examples.
Check out the API documentation.
You can find more libraries (all multiplatform) of mine that all do work together nicely here.