https://github.com/janloebel/mailthat
MailThat is a kind of proxy/service to forward mails from HTTP-Requests or received via SMTP.
https://github.com/janloebel/mailthat
http mail proxy rest smtp
Last synced: 2 months ago
JSON representation
MailThat is a kind of proxy/service to forward mails from HTTP-Requests or received via SMTP.
- Host: GitHub
- URL: https://github.com/janloebel/mailthat
- Owner: JanLoebel
- License: mit
- Created: 2021-04-18T13:45:52.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-18T13:46:51.000Z (about 5 years ago)
- Last Synced: 2025-01-27T06:12:46.724Z (over 1 year ago)
- Topics: http, mail, proxy, rest, smtp
- Language: TypeScript
- Homepage:
- Size: 91.8 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MailThat
MailThat is a kind of proxy/service to forward mails from HTTP-Requests or received via SMTP.

## 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](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`
|
| `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`
|
| `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
- [mailit](https://github.com/Rahul-Bisht/mailit)
-