Mailer API
A mailer instance is connected to an SMTP server capable of sending emails (e.g. Postfix, paid services or Gmail).
For a list of free SMTP servers have a look into this list by mailtrap. If you want to configure a send-only postfix server, read this tutorial.
Create a Mailer
Set the global default Mailer
The default mailer will be used for sending emails if no specific mailer is passed as a parameter.
Shutdown all Mailers
The mailer instances keep your program alive. In order to exit your program safely, you have to shut down the mailer instances.
Send emails
Easily send your previously built emails.
Using coroutines (Asynchronously)
This approach allows you to send emails without blocking the current thread. These methods only work within a CoroutineScope
.
Suspend until completion
The send function returns a Job
, therefore you can just join it.
This can thrown an exception of the delivery failed, you can handle that like this:
Synchronously
If you need to send your emails synchronously for some reason, you can do that. This function will throw an exception if the action fails, otherwise (on success) it will just pass.