Add docs for how to create a smtp gateway

This commit is contained in:
Eike Kettner
2020-06-14 21:35:20 +02:00
parent 151e831b1c
commit 09579eef16
11 changed files with 320 additions and 15 deletions

14
tools/exim/README.md Normal file
View File

@ -0,0 +1,14 @@
# SMTP Gateway via Docker
This is an example setup for a SMTP server that forwards all incoming
mails to docspell via `curl`.
The docker image contains [exim](https://exim.org) and a sample config
file that runs curl against a configurable docspell url. It uses the
[integration
endpoint](https://docspell.org/doc/uploading#integration-endpoint) and
it expects it to be configured with "http-header" protection. It can
be easily adopted to use a different protection method.
Please see the [documentation
page](https://docspell.org/doc/tools/smtpgateway) for a guide.

View File

@ -0,0 +1,13 @@
version: '3.7'
services:
smtp:
image: ds-exim:latest
ports:
- "25:25"
environment:
# This is the configured header value for the integration-endpoint
- DS_HEADER=test123
# This is the URL to docspell
- DS_URL=http://192.168.1.95:7880
# Use host network for demo purposes
network_mode: host

57
tools/exim/exim.conf Normal file
View File

@ -0,0 +1,57 @@
## Provide certificates to enable StartTLS
# tls_certificate = /var/lib/acme/test.org/fullchain.pem
# tls_privatekey = /var/lib/acme/test.org/key.pem
tls_advertise_hosts =
primary_hostname = test.org
domainlist local_domains = test.org
timeout_frozen_after = 1m
acl_smtp_rcpt = acl_check_rcpt
acl_smtp_data = acl_check_data
never_users = root
host_lookup = *
daemon_smtp_ports = 25
message_size_limit = 30m
keep_environment = DS_HEADER : DS_URL
begin acl
acl_check_rcpt:
require
domains = +local_domains
require
message = Sender verification failed
verify = sender
require
message = Receiver verification failed
verify = recipient
require
message = Recipient unknown
condition = ${run{/usr/bin/curl --out /dev/null --silent --fail -H "Docspell-Integration: ${env{DS_HEADER}{$value} fail}" "${env{DS_URL}{$value} fail}/api/v1/open/integration/item/$local_part"}{yes}{no}}
warn
message = Reverse lookup failed
!verify = reverse_host_lookup
accept
acl_check_data:
deny
message = Sender verification failed
!verify = header_sender
accept
begin routers
local_users:
driver = accept
transport = docspell
begin transports
docspell:
driver = pipe
command = /usr/bin/curl --out /dev/null --silent --fail -H "Docspell-Integration: ${env{DS_HEADER}{$value} fail}" -F "file=@-;filename=\"$h_subject:\"" "${env{DS_URL}{$value} fail}/api/v1/open/integration/item/$local_part"
return_fail_output
user = nobody
delivery_date_add
envelope_to_add
return_path_add
log_output

View File

@ -0,0 +1,8 @@
FROM alpine:latest
RUN apk add --no-cache exim curl
USER exim
COPY ./exim.conf /etc/exim/
EXPOSE 25
ENTRYPOINT ["exim"]
CMD ["-bdf", "-v", "-q1m"]