SMTP backend implementation for sendr. sendr-smtp.hexdocs.pm
gleam sendr emall smtp
Gleam 97%
Erlang 3%

README.md

sendr_smtp #

Package Version Hex Docs

An SMTP backend for sendr. It delivers email messages over SMTP, optionally with TLS and authentication.

It tries to adhere to the SMTPUTF8, 8BITMIME, STARTTLS, AUTH and SIZE extensions and of course to all relevant RFC's.

WARNING Dispite extensive testing no guarantee is given the spec is followed flawless and interaction with every SMTP-server will work.

50+ years of extensions on top of the original SMTP en Internet Message specification make it hard to navigate this labyrinth of RFC's. I've done my best to implement this library according to the relevant RFC's (as listed below) and keeping the code sane and testable. However I might have failed at this. Any bug reports are appreciated, but no promises are made I will, or even will be able to fix them.

gleam add sendr sendr_smtp

Usage #

import sendr/message
import sendr/message/mailbox
import sendr/message/body
import sendr_smtp

pub fn send_email() {
  let config =
    sendr_smtp.config("smtp.example.com", 587)
    |> sendr_smtp.credentials("user", "pass")

  let msg =
    message.new()
    |> message.set_from(mailbox.new("Señora Alice", "alice@example.com"))
    |> message.set_to([mailbox.new("Bob", "bob@example.com"]))
    |> message.set_subject("Hola, señora")
    |> message.set_body(body.empty |> body.set_text("¡Hola desde Gleam!"))

  sendr_smtp.deliver(msg, with: config)
}

Implemented RFCs #

RFC Description
RFC 822 ARPA Internet Text Messages (structured/unstructured header field types)
RFC 2045 MIME Part One: base64, bit encoding, quoted-printable, and text encoding
RFC 2047 MIME Part Three: Message Header Extensions for Non-ASCII Text
RFC 3986 Uniform Resource Identifier: percent-encoding
RFC 5321 Simple Mail Transfer Protocol
RFC 5322 Internet Message Format
RFC 5890 Internationalized Domain Names for Applications (IDNA)
RFC 6854 Updates to RFC 5322

Development #

gleam test                                   # Run the tests
gleam run -m devutils/glinter -- --stats     # Run the code style checks