package sihl-email

  1. Overview
  2. Docs
Email service implementations for Sihl

Install

Dune Dependency

Authors

Maintainers

Sources

3.0.4.tar.gz
md5=8a2754d6e5b9eafb8ff332abdb1ceb7d
sha512=3230a1315686b0b6f90a41ceda27ab036e178184ab13d5a98f64d6d987caf4a8a5d94ed78bc8e79b0ee3b40ccbb1dbdc71ffe171f1aef1f18aba81fc720e3a1b

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. The functor argument has to have a fetch function that takes a unit and returns the configuration for the backend wrapped in Lwt.t. This allows reading the config from IO.

module MarketingSmtpConfig = struct
  let fetch () = Lwt.return {sender="marketing@mail.io"; username=...}
end

module CustomerServiceSmtpConfig = struct
  let fetch () = Lwt.return {sender="help@mail.io"; username=...}
  ...
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 config to get a list of required configurations.

You can use EMAIL_BYPASS_INTERCEPT to actually use a configured SMTP server in a development setting (without having to set SIHl_ENV to production).

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.