Skip to content

TypeMailer - An E-Mail Library for Scala with multiple Backends

License

Notifications You must be signed in to change notification settings

acme-software/typemailer

Repository files navigation

TypeMailer - An E-Mail Library for Scala with multiple Backends

Build Status Codacy Badge

This is absolutely work-in-progress and by no means production-ready

Features

  • Generic mailing lib for multiple backends:
    • SMTP (TODO)
    • MailGun (TODO)
    • Slf4J
    • Filesystem (TODO)
    • Callback (debug)
  • Tagless final API to use with any IO monad
    • Reference implementation with cats-effect
    • More to follow

In the examples, the cats-effect IO monad is used

Usage

The library is splitted in senders and receivers, because some backends (e.g. mailgun) can only send. YOu can use different backends for sending and receiving.

Every sender / receiver needs a concrete adapter implementation, which is specific by backend. In the following examples, the LogAdapter, which just logs every sent mail with SLF4J, is used:

import ch.acmesoftware.typemailer.adapter.debug.LogAdapter
import ch.acmesoftware.typemailer.catseffect._
import ch.acmesoftware.typemailer.core.Mail
import org.slf4j.LoggerFactory

val sendMail = for {
  sender <- Sender(LogAdapter(LoggerFactory.getLogger("test")))
  mail <- Mail.
    from("[email protected]").
    to("[email protected]").
    to("[email protected]").
    subject("Test Subject").
    pureIO
  _ <- sender.send(mail)
} yield ()

sendMail.unsafeRunSync

About

TypeMailer - An E-Mail Library for Scala with multiple Backends

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages