Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

268 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rest2smtp

Send mails via REST API

API documentation is served by the program under the root path (/). It's also available here.

Config

Env Var Description
SMTP_HOST Hostname (required)
SMTP_PORT (default depends on encryption method)
SMTP_ENCRYPTION TLS (default), STARTTLS, UNENCRYPTED (insecure)
SMTP_USERNAME (optional)
SMTP_PASSWORD (optional)
API_TOKEN When set, HTTP request header Authorization: Bearer <token> must be present. (optional)
API_DOC_INFO Custom text (or HTML) to be displayed in API documentation header. Defaults to "Send mails via REST API" (optional)

Deployment

Docker

docker run -p 8080:80 -e SMTP_HOST=smtp.example.org -e SMTP_USERNAME=user -e SMTP_PASSWORD=password knrdl/rest2smtp

Open the API documentation: http://localhost:8080/

curl -X POST http://localhost:8080/send -F 'subject=Test' -F 'content_html=Hi there' -F 'to_address=info@example.invalid'

Docker Compose

services:
  rest2smtp:
    image: knrdl/rest2smtp  # or alternative: ghcr.io/knrdl/rest2smtp
    hostname: rest2smtp
    environment:
      SMTP_HOST: smtp.example.org  # replace this
      # see config table above for optional settings
    ports:
      - "80:80"

NixOS

{ ... }:
{
  imports = [ ./path/to/rest2smtp/nix/module.nix ];

  services.rest2smtp = {
    enable = true;
    port = 8080;
    smtp = {
      host = "smtp.example.org";
      # username = "user";
      # passwordFile = "/etc/rest2smtp.pass";
    };
    # Optional: require Authorization: Bearer <token> on POST /send
    # apiTokenFile = "/etc/rest2smtp.token";
  };
}

Build the package from this repository (no GitHub source fetch):

nix-build -E 'with import <nixpkgs> {}; callPackage ./nix/package.nix {}'

Manual build

# in project root dir
docker run -it --rm -v "$PWD:$PWD" -w "$PWD" -p8080:80 --env-file env docker.io/library/rust
$ cargo run

About

Send mails via REST API

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages