package sihl-email

  1. Overview
  2. Docs
Email service implementations for Sihl

Install

Dune Dependency

Authors

Maintainers

Sources

0.4.1.tar.gz
md5=b4d86577876e268da4219d29f0f3207e
sha512=e5ad0fffa52dc7dad72b84b49d375316342704e9414afe6da7a3be96cf9595cfbb5f792e9e20a7958f3fad1708f5005964daf29dc81e80923c86750441b82567

doc/index.html

Sihl Email

This module provides the email service and the email template service.

Email service

The email service provides API for sending emails. Currently SMTP and Sendgrid are supported.

Installation

Backend

First, choose a backend in service/service.ml:

module Email = Sihl_email.Smtp

If you want to use the same backend multiple times with different configs, you can use the Make functors with a config. The config fields are functions that take () and return a value wrapped in Lwt.t. This allows reading these config fields from IO.

module MarketingSmtpConfig = struct
  let sender () = Lwt.return "marketing@mail.io"
  ...
end

module CustomerServiceSmtpConfig = struct
  let sender () = Lwt.return "help@mail.io"
  ...
end

module MarketingMail = Sihl_email.MakeSmtp (MarketingSmtpConfig)
module CustomerServiceMail = Sihl_email.MakeSmtp (CustomerServiceSmtpConfig)

Registration

Then, register the service in run/run.ml:

let services = [ Service.Email.register () ]

Configuration

Run make sihl to get a list of required configurations.

Usage

The API is documented in Sihl.Contract.Email.Sig.

Template service

The template service can be used to create and edit email templates. Email templates are rendered with parameters to emails, that can be sent with the email service. Currently MariaDb (Sihl_cache.MariaDb) and PostgreSql (Sihl_cache.PostgreSql) are supported.

Installation

Backend

First, choose a backend in service/service.ml:

module Email_template = Sihl_email.Temlate.PostgreSql

Registration

Then, register the service in run/run.ml:

let services = [ Service.Email_template.register () ]

Migrations

Run make sihl migrate to run pending migrations.

Usage

The API is documented in Sihl.Contract.Email_template.Sig.

OCaml

Innovation. Community. Security.