nedimf / maildroid

Maildroid is a small robust android library for sending emails using SMTP server
188 stars 24 forks source link

Kotlnizing implementation by allowing the use of DSL #5

Closed javier-moreno closed 5 years ago

javier-moreno commented 5 years ago

Description

Implementation of a couple of functions to allow to have a more kotlinized approach to using this library through a simple DSL definition.

Updated the README.md to reflect this new way of sending an email.

Code Sample

sendEmail {
      smtp("smtp.mailtrap.io")
      smtpUsername("username")
      smtpPassword("password")
      smtpAuthentication(true)
      port("2525")
      type(MaildroidXType.HTML)
      to("johndoe@email.com")
      from("janedoen@email.com")
      subject("Hello!")
      body("email body")
      attachment("path_to_file/file.txt")
      callback {
          timeOut(3000)
          onSuccess {
              Log.d("MaildroidX",  "SUCCESS")
          }
          onFail {
              Log.d("MaildroidX",  "FAIL")
          }
      }
 }