Skip to content

andre-dasilva/gsmtp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gsmtp

SMTP Client for Gleam

Package Version Hex Docs

Further documentation can be found at https://hexdocs.pm/gsmtp.

RFC

Current state

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)
}

TODO

  • TLS
  • Auth
  • Extensions
  • Tests
  • Error handling
  • Docs
  • Cleanup API

Development

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

About

SMTP Client for gleam

Resources

Stars

Watchers

Forks

Packages

No packages published