JanLoebel / mailthat

MailThat is a kind of proxy/service to forward mails from HTTP-Requests or received via SMTP.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MailThat

MailThat is a kind of proxy/service to forward mails from HTTP-Requests or received via SMTP.

Foo

WORK IN PROGRESS - HELP IS WELCOME**

  • Test real email server (outgoing smtp options)
  • Add example key / cert file for secure serving
  • Add smtp tests
  • Add more documentation how to configure and run
  • Add form based submit
  • Add more predefined authentication strategies for HTTP
  • https://www.npmjs.com/package/tslog -> Add request id for http logging

Basic idea

Providing a small service to fullfil two services regarding sending emails.

HTTP

If you just want a HTTP-API to send emails with overwritable properties you can just use MailThat to provide these API.

SMTP

While using different services (Wordpress, others..) you always have to configure a mail services. But what if you use e.g.: a private GMAIL account. And you don't want to enter you're password in different services? With MailThat you can just create a new user and enter these credentials to the services and just use the real credentials in MailThat itself. So MailThat will work as a MailRelay.

How to start

Basically there are two ways, use the source code or simply use docker to start the service.

Source Code

  • Start by cloning the repository: git clone https://github.com/JanLoebel/mailthat.git
  • Change into the cloned directory: cd mailthat
  • Run npm install to install all needed dependencies
  • If you just want to start mailthat run: npm start
  • If you want to start mailthat and watch for changes run: npm run start:dev

Docker

The docker image is published to the docker hub registry. Therefore it's pretty simple to use docker to get started. In the directory docker-example you can find an example config and docker-compose file. The docker-compose file just start the docker image with the config directory as a mounted volume to provide the example config to the service. If you don't want to use docker-compose you can also change to the docker-example directory and execute docker run -it --rm -v $(pwd)/config:/config mailthat.

Configuration options

The configuration is a json file which will be validated on startup. For an example file checkout config/config.json or docker-example/config/config.json. They are more easy readable then the available options here ;)

Option Description
outgoingSmtp Required Server configuration, see OutgoingSmtp configuration options.

Type: object
httpServices Optional Array of HttpServices, see HttpServices configuration options.

Type: array
smtpServices Optional Array of SmtpServices, see SmtpServices configuration options.

Type: array

OutgoingSmtp configuration options

Option Description
host Required Server port to listen.

Type: string
port Required Server port to listen.

Type: number
Default: 3000
ignoreTLS Optional Server port to listen.

Type: boolean
Default: 3000
secure Optional Server port to listen.

Type: boolean
Default: 3000

HttpServices configuration options

Option Description
port Required HTTP-Server port to listen.

Type: number
auth Optional Authentication options, see HTTP Authentication options.

Type: object
defaults Optional Default values, see Defaults configuration options.

Type: object

Http Authentication configuration options

Option Description
type Required Which type should be used. Options: basic

Type: string
username Required if type === basic Username for basic authentication.

Type: string
password Required if type === basic Password for basic authentication.

Type: string

SmtpServices configuration options

Option Description
port Required SMTP-Server port to listen.

Type: number
auth Optional Authentication options, see SMTP Authentication options.

Type: object
defaults Optional Default values, see Defaults configuration options.

Type: object
allowedIps Optional The ip values of clients that are allowed to connect, e.g: 127.0.0.1 then only the local host can connect to the smtp server.

Type: array<string>
secure Optional Should the smtp services served secure, if you want to enable it you will have to provide the file path to the key and cert-files as an object.

Type: false | object
secure.cert Required if secure File path to the cert-file.

Type: string
secure.key Required if secure File path to the key-file.

Type: string

Smtp Authentication configuration options

Option Description
type Required Which type should be used. Options: basic

Type: string
username Required if type === basic Username for basic authentication.

Type: string
password Required if type === basic Password for basic authentication.

Type: string

Defaults configuration options

Option Description
to Optional Define email recipient (overwrites the value received if defined).

Type: string | array<string>
from Optional Define email sender (overwrites the value received if defined).

Type: string
subject Optional Define email subject (overwrites the value received if defined).

Type: string
text Optional Define email text/body (overwrites the value received if defined).

Type: string

Contribution

Please feel free to improve or modify the code and open a Pull-Request! Any contribution is welcome :)

License

MIT License

Copyright (c) 2021 Jan Löbel

See LICENSE file for details.

Alternative projects

About

MailThat is a kind of proxy/service to forward mails from HTTP-Requests or received via SMTP.

License:MIT License


Languages

Language:TypeScript 97.7%Language:Dockerfile 1.6%Language:JavaScript 0.7%