- Rust 100%
|
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
|
||
|---|---|---|
| src | ||
| .gitignore | ||
| .woodpecker.yaml | ||
| Cargo.lock | ||
| Cargo.toml | ||
| config.example.toml | ||
| LICENSE | ||
| README.md | ||
| renovate.json | ||
SMTP - Simple Mail Transfer Gateway
I recently had some problems with hosting providers blocking SMTP connections, and a very specific one where ipv6 smtp traffic wasn't possible, but http was. This is my solution
Installation
SMTG is a single compiled binary with no special dependencies except glibc (and not even that if you compile with the right toolchain, but because of hardware limits CI only builds for glibc). Go to the latest release, grab the binary and simply start it.
Configuration
SMTG has to be configured with a config file. The location of the file has to be passed as the first (and only!) argument to the SMTG command. Have a look at config.example.toml for an example.
Sending mail via http
It's incredibly simple, really. Just POST agains /send this json body:
{
"from": "noreply@example.com",
"to": "alice@example.com",
"name": "Alice",
"subject": "I'm sending this mail using SMTG!",
"message": "This could be a simple string, or full blown email HTML. Do what you please!"
}
If everything goes right, you'll get this back:
{
"data": {
"to": "alice@example.com",
"from": "noreply@example.com",
"name": "Alice",
"subject": "I'm sending this mail using SMTG!",
"message": "This could be a simple string, or full blown email HTML. Do what you please!"
}
}
If anything goes wrong while sending the mail, you'll get this:
{
"error": {
"error_code": 4,
"message": "Failed to send Email. Check logs for error message",
"data": "could not send SMTP mail"
}
}
TODO:
datashould at some point actually contain some useful information, but I currently don't know how I can get those from the mailer api. Sorry!
Authorization using Headers
SMTG has rudimentary support for header authentication. If you set auth.secret to something, it will compare that to the Authorization header of the request, and only allow those with the correct header.
License
AGPL, have fun!