Email for an application: build a mailer from configuration once, then send! a
message with it.
(def mailer (mail/mailer {:transport :console :from "noreply@example.com"}))
(mail/send! mailer {:to "ada@example.com" :subject "Hello" :text "…"})
Two transports, chosen by :transport:
:console prints the whole message — headers and body — to *out* and sends
nothing. It is for development, where a sign-in link should be readable in the
terminal: in production it would put credentials in the logs, which the host
refuses (this library cannot know what production is).:smtp delivers through a submission server with this library's own client
(dev.arkaitz.sendmail-base.smtp, SPEC §5): TLS always, a required wall-clock
deadline on every send, and refusals that never echo a recipient, a server's text
or a password.A mailer is a value. It holds no connection and no thread: every send! connects,
delivers one message and closes, inside its deadline.
Email for an application: build a mailer from configuration once, then `send!` a
message with it.
(def mailer (mail/mailer {:transport :console :from "noreply@example.com"}))
(mail/send! mailer {:to "ada@example.com" :subject "Hello" :text "…"})
Two transports, chosen by `:transport`:
- `:console` prints the whole message — headers and body — to `*out*` and sends
nothing. It is for development, where a sign-in link should be readable in the
terminal: in production it would put credentials in the logs, which the host
refuses (this library cannot know what production is).
- `:smtp` delivers through a submission server with this library's own client
(`dev.arkaitz.sendmail-base.smtp`, SPEC §5): TLS always, a required wall-clock
deadline on every send, and refusals that never echo a recipient, a server's text
or a password.
A mailer is a value. It holds no connection and no thread: every `send!` connects,
delivers one message and closes, inside its deadline.(address s)s as an address this library will put in an envelope and a header — the domain
in its ASCII form — or nil when it is not one: a local part of printable ASCII with
none of the characters that would let it escape a header or an SMTP command, and a
domain of letters, digits, hyphens and dots, at least two labels. A non-ASCII local
part would need SMTPUTF8, which this version does not speak; a quoted one, and a local
part past 64 octets, no submission server takes.
`s` as an address this library will put in an envelope and a header — the domain in its ASCII form — or nil when it is not one: a local part of printable ASCII with none of the characters that would let it escape a header or an SMTP command, and a domain of letters, digits, hyphens and dots, at least two labels. A non-ASCII local part would need SMTPUTF8, which this version does not speak; a quoted one, and a local part past 64 octets, no submission server takes.
(mailer config)A mailer for config, refused at once — naming the key, never the value — when it
could not send:
{:transport :console :from address}{:transport :smtp :from address :host h :port p :tls :implicit|:starttls|:none :user u :password pw :deadline-ms n}:tls :none is for a server on this machine only, and never with a password.
:deadline-ms bounds each send! from the first byte to the last, connecting
included, and has no default. :ssl-context replaces the JVM's default trust, for
a server whose certificate a private authority signed.
A mailer for `config`, refused at once — naming the key, never the value — when it
could not send:
- `{:transport :console :from address}`
- `{:transport :smtp :from address :host h :port p :tls :implicit|:starttls|:none
:user u :password pw :deadline-ms n}`
`:tls :none` is for a server on this machine only, and never with a password.
`:deadline-ms` bounds each `send!` from the first byte to the last, connecting
included, and has no default. `:ssl-context` replaces the JVM's default trust, for
a server whose certificate a private authority signed.(send! mailer message)Sends message, {:to address :subject string :text string}, with mailer, and
answers nil, or throws: an ex-info naming the key of a malformed message before
anything is sent, or one naming the stage and the server's reply code when the
server refused it or did not answer within the mailer's deadline. Neither names the
recipient, carries the server's text or the body, nor echoes a password.
Sends `message`, `{:to address :subject string :text string}`, with `mailer`, and
answers nil, or throws: an `ex-info` naming the key of a malformed message before
anything is sent, or one naming the stage and the server's reply code when the
server refused it or did not answer within the mailer's deadline. Neither names the
recipient, carries the server's text or the body, nor echoes a password.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |