Skip to content

Latest commit

 

History

History

smtp

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

klite-smtp

Provides a way to send plain text or html email over SMTP using javax.mail.

Depends on klite-i18n for translations.

To use it, initialize the correct implementation when creating the Server instance:

register(if (Config.isDev) FakeEmailSender::class else SmtpEmailSender::class)

Add approprate content to your translation files, e.g. en.json:

{
  "emails": {
    "welcome": {
      "subject": "Welcome to our service",
      "body": "Hello, {name}! Welcome to our service.",
      "action": "Click here to login"
    }
  }
}

Then you can send emails like this:

emailSender.send(Email("[email protected]"), EmailContent("en", "welcome", mapOf("name" to "John"), URI("https://github.com/login")))

You can redefine HTML email template by extending EmailContent class.