# sendr_smtp
[](https://hex.pm/packages/sendr_smtp)
[](https://hexdocs.pm/sendr_smtp/)
An SMTP backend for [sendr](https://hex.pm/packages/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.
```sh
gleam add sendr sendr_smtp
```
## Usage
```gleam
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](https://tools.ietf.org/html/rfc822) | ARPA Internet Text Messages (structured/unstructured header field types) |
| [RFC 2045](https://tools.ietf.org/html/rfc2045) | MIME Part One: base64, bit encoding, quoted-printable, and text encoding |
| [RFC 2047](https://tools.ietf.org/html/rfc2047) | MIME Part Three: Message Header Extensions for Non-ASCII Text |
| [RFC 3986](https://tools.ietf.org/html/rfc3986) | Uniform Resource Identifier: percent-encoding |
| [RFC 5321](https://tools.ietf.org/html/rfc5321) | Simple Mail Transfer Protocol |
| [RFC 5322](https://tools.ietf.org/html/rfc5322) | Internet Message Format |
| [RFC 5890](https://tools.ietf.org/html/rfc5890) | Internationalized Domain Names for Applications (IDNA) |
| [RFC 6854](https://tools.ietf.org/html/rfc6854) | Updates to RFC 5322 |
## Development
```sh
gleam test # Run the tests
gleam run -m devutils/glinter -- --stats # Run the code style checks
```