SMTP Client for Gleam
Further documentation can be found at https://hexdocs.pm/gsmtp.
A simple mail to a SMTP server can be sent
Use it like this
gleam add gsmtp
import gsmtp/builder
import gsmtp/smtp
import logging
pub fn main() {
logging.configure()
logging.set_level(logging.Debug)
let message =
builder.new_builder()
|> builder.from_email("[email protected]")
|> builder.to_emails(["user@localhost"])
|> builder.subject("SMTP Mail from gleam")
|> builder.body("This is a test mail from gleam")
|> builder.create()
let assert Ok(Nil) = smtp.send("127.0.0.1", 25, message)
}
- TLS
- Auth
- Extensions
- Tests
- Error handling
- Docs
- Cleanup API
Setup postfix (ubuntu) for a local SMTP server
sudo apt install postfix
Make sure to setup postfix to send mails only locally
For just simple SMTP command tests you can use telnet
telnet localhost 25
and run the following commands
HELO localhost
MAIL FROM:<[email protected]>
RCPT TO:<user@localhost>
DATA
Subject: Test Email
From: [email protected]
To: user@localhost
This is a test email sent manually.
.
QUIT
This is basically what the library does. it opens a TCP connection and runs the commands
Run the following command to see the mails:
tail -f /var/mail/user
To test the gleam smtp client run
gleam test
This project is inspired by the go smtp package
Thats why there is a working smtp client in the go/
directory.
Run it with
go run go/main.go