dymokomi/luce-smtp
An SMTP submission client in luce-base: EHLO and its extensions, STARTTLS and implicit TLS, AUTH PLAIN/LOGIN/XOAUTH2, MAIL/RCPT/DATA with dot-stuffing, SIZE, 8BITMIME and SMTPUTF8, and every reply code kept for the caller.
A library written in luce-base. Latest release 0.6.0.
Install#
luc add dymokomi/luce-smtpDocumentation#
luce-smtp
An SMTP submission client in luce-base (RFC 6409 / RFC 5321). It reads EHLO and its extensions, then STARTTLS (587) or implicit TLS (465) through a luce-tls Stream, then AUTH PLAIN, LOGIN or XOAUTH2. Messages go as MAIL / RCPT / DATA with dot-stuffing, and SIZE, 8BITMIME and SMTPUTF8 are used when the server offers them. Every reply's code and text are kept for the caller.
from luce_smtp import smtp
var client = try smtp.Client.open("smtp.example.com", 587, smtp.Security.starttls)
defer client.close()
try client.login("alice@example.com", password)
let recipients: str[2] = ["bob@example.org", "carol@example.net"]
let accepted = try client.send("alice@example.com", recipients, message_bytes)
for index in 0..<client.refused_count():
print(f"refused: {try client.refused(index)}")
client.quit()
send delivers to every recipient the server accepts. Refused recipients are listed by refused, and the send fails with no_recipients only when none was accepted. A 4xx reply fails with deferred (try again later) and a 5xx with rejected, each carrying the server's text. The message bytes are sent with CRLF line ends whatever they had. Build them with luce-mime's Draft. Every read and write has a deadline and can be cancelled from another thread.
Test
./test.sh # sessions against a scripted loopback server
tools/live.lucb sends one test message through a real server: build/live HOST PORT plain|starttls|tls FROM TO [USER PASSWORD].
License
Dual-licensed under Apache-2.0 or MIT, at your option.
Dependencies#
| Package | Version |
|---|---|
| dymokomi/luce-std | newest |
| dymokomi/luce-tls | newest |
Versions#
0.6.0
Browse source · pack · commit ab46f7afd250
SHA-256 9942179858f640a4076d043d1287ca5379293f6a088b698d03a31bdbf31d8a7c
byte spans compare with ==; dependencies name no version