18 Mail
(require koyo/mail) | package: koyo-lib |
This module provides functionality for sending e-mail.
18.1 Mailer
The mailer is a component that wraps a mail-adapter? along with a default value for the sender and common variables for some of the template model properties.
procedure
(make-mailer-factory #:adapter adapter #:sender sender #:common-variables common-variables) → (-> mailer?) adapter : mail-adapter? sender : non-empty-string? common-variables : (hash/c symbol? string?)
procedure
m : mailer?
procedure
(mailer-send-email m #:to to [ #:from from] #:subject subject [ #:text-content text-content #:html-content html-content]) → void? m : mailer? to : non-empty-string? from : non-empty-string? = (mailer-sender m) subject : non-empty-string? text-content : (or/c #f string?) = #f html-content : (or/c #f string?) = #f
Added in version 0.8 of package koyo-lib.
procedure
(mailer-send-email-with-template m #:to to [ #:from from #:template-id template-id #:template-alias template-alias #:template-model template-model]) → void? m : mailer? to : non-empty-string? from : non-empty-string? = (mailer-sender m) template-id : (or/c #f exact-positive-integer?) = #f template-alias : (or/c #f symbol?) = #f template-model : (hash/c symbol? string?) = (hasheq)
The #:template-model hash is merged with the #:common-variables the mailer was created with prior to being passed to mail-adapter-send-email-with-template.
18.2 Adapters
Mail adapters expose a consistent interface for values that can send e-mail.
interface
procedure
(mail-adapter? v) → boolean?
v : any/c
procedure
(mail-adapter-send-email adapter #:to to #:from from #:subject subject [ #:text-content text-content #:html-content html-content]) → void? adapter : mail-adapter? to : non-empty-string? from : non-empty-string? subject : non-empty-string? text-content : (or/c #f string?) = #f html-content : (or/c #f string?) = #f
procedure
(mail-adapter-send-email-with-template adapter #:to to #:from from [ #:template-id template-id #:template-alias template-alias] #:template-model template-model) → void? adapter : mail-adapter? to : non-empty-string? from : non-empty-string? template-id : (or/c exact-positive-integer?) = #f template-alias : (or/c symbol?) = #f template-model : (hash/c symbol? string?)
The #:template-id and #:template-alias arguments to mail-adapter-send-email-with-template are mutually exclusive.
procedure
procedure
(stub-mail-adapter? v) → boolean?
v : any/c
procedure
(stub-mail-adapter-outbox adapter) → (listof hash?)
adapter : stub-mail-adapter?
18.2.1 Other Adapters
koyo-postmark provides a mail adapter for interfacing with the Postmark API.