refrakt/mailer
Email sending abstraction.
Experimental. This module is lightly used and may change or move to its own package; see https://github.com/raskell-io/refrakt/issues/28.
Provides a simple interface for sending emails. In development, emails are logged to the console. In production, plug in an SMTP or API-based adapter.
Usage
import refrakt/mailer
let email = mailer.new()
|> mailer.to("user@example.com")
|> mailer.from("noreply@myapp.com")
|> mailer.subject("Welcome!")
|> mailer.text_body("Thanks for signing up.")
|> mailer.html_body("<h1>Welcome!</h1>")
mailer.deliver(email, mailer.log_adapter())
Types
Values
pub fn deliver(
email: Email,
adapter: fn(Email) -> Result(Nil, String),
) -> Result(Nil, String)
Deliver an email using the given adapter.
pub fn log_adapter() -> fn(Email) -> Result(Nil, String)
Log adapter — prints emails to console. Use in development.