mirror of
https://blitiri.com.ar/repos/chasquid
synced 2026-01-27 20:45:56 +00:00
WIP: Add smarthost support
WORK IN PROGRESS -- WORK IN PROGRESS -- WORK IN PROGRESS This patch adds support for delivering mail via a smarthost. In this mode, all accepted mail gets delivered through an SMTP connection to a specific host, statically configured.
This commit is contained in:
17
test/t-20-smarthost/A/chasquid.conf
Normal file
17
test/t-20-smarthost/A/chasquid.conf
Normal file
@@ -0,0 +1,17 @@
|
||||
smtp_address: ":1025"
|
||||
submission_address: ":1587"
|
||||
submission_over_tls_address: ":1465"
|
||||
monitoring_address: ":1099"
|
||||
|
||||
# We don't expect this to be used, pick something that will error to ease
|
||||
# troubleshooting.
|
||||
mail_delivery_agent_bin: "no_mda_needed"
|
||||
|
||||
data_dir: "../.data-A"
|
||||
mail_log_path: "../.logs/mail_log-A"
|
||||
|
||||
# srv-b is our smarthost.
|
||||
# We use tls protocol because the smtp one is already well exercised in the
|
||||
# package tests.
|
||||
smarthost_url: "tls://userB@srv-b:userB@srv-b:2465"
|
||||
|
||||
0
test/t-20-smarthost/A/domains/srv-A/aliases
Normal file
0
test/t-20-smarthost/A/domains/srv-A/aliases
Normal file
10
test/t-20-smarthost/B/chasquid.conf
Normal file
10
test/t-20-smarthost/B/chasquid.conf
Normal file
@@ -0,0 +1,10 @@
|
||||
smtp_address: ":2025"
|
||||
submission_address: ":2587"
|
||||
submission_over_tls_address: ":2465"
|
||||
monitoring_address: ":2099"
|
||||
|
||||
mail_delivery_agent_bin: "test-mda"
|
||||
mail_delivery_agent_args: "%to%"
|
||||
|
||||
data_dir: "../.data-B"
|
||||
mail_log_path: "../.logs/mail_log-B"
|
||||
0
test/t-20-smarthost/B/domains/srv-B/aliases
Normal file
0
test/t-20-smarthost/B/domains/srv-B/aliases
Normal file
10
test/t-20-smarthost/C/chasquid.conf
Normal file
10
test/t-20-smarthost/C/chasquid.conf
Normal file
@@ -0,0 +1,10 @@
|
||||
smtp_address: ":3025"
|
||||
submission_address: ":3587"
|
||||
submission_over_tls_address: ":3465"
|
||||
monitoring_address: ":3099"
|
||||
|
||||
mail_delivery_agent_bin: "test-mda"
|
||||
mail_delivery_agent_args: "%to%"
|
||||
|
||||
data_dir: "../.data-C"
|
||||
mail_log_path: "../.logs/mail_log-C"
|
||||
0
test/t-20-smarthost/C/domains/srv-C/aliases
Normal file
0
test/t-20-smarthost/C/domains/srv-C/aliases
Normal file
9
test/t-20-smarthost/content
Normal file
9
test/t-20-smarthost/content
Normal file
@@ -0,0 +1,9 @@
|
||||
From: userA@srv-A
|
||||
To: userC@srv-C
|
||||
Subject: Los espejos
|
||||
|
||||
Yo que sentí el horror de los espejos
|
||||
no sólo ante el cristal impenetrable
|
||||
donde acaba y empieza, inhabitable,
|
||||
un imposible espacio de reflejos
|
||||
|
||||
3
test/t-20-smarthost/hosts
Normal file
3
test/t-20-smarthost/hosts
Normal file
@@ -0,0 +1,3 @@
|
||||
srv-A localhost
|
||||
srv-B localhost
|
||||
srv-C localhost
|
||||
14
test/t-20-smarthost/msmtprc
Normal file
14
test/t-20-smarthost/msmtprc
Normal file
@@ -0,0 +1,14 @@
|
||||
account default
|
||||
|
||||
host srv-A
|
||||
port 1587
|
||||
|
||||
tls on
|
||||
tls_trust_file A/certs/srv-A/fullchain.pem
|
||||
|
||||
from userA@srv-A
|
||||
|
||||
auth on
|
||||
user userA@srv-A
|
||||
password userA
|
||||
|
||||
60
test/t-20-smarthost/run.sh
Executable file
60
test/t-20-smarthost/run.sh
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
. $(dirname ${0})/../util/lib.sh
|
||||
|
||||
init
|
||||
|
||||
rm -rf .data-A .data-B .data-C .mail .logs
|
||||
|
||||
# Build with the DNS override, so we can fake DNS records.
|
||||
export GOTAGS="dnsoverride"
|
||||
|
||||
# Launch minidns in the background using our configuration.
|
||||
minidns_bg --addr=":9053" -zones=zones >> .minidns.log 2>&1
|
||||
|
||||
# 3 servers:
|
||||
# A - listens on :1025, hosts srv-A
|
||||
# B - listens on :2015, hosts srv-B
|
||||
# C - listens on :3015, hosts srv-C
|
||||
#
|
||||
# B and C are normal servers.
|
||||
# A will use B as a smarthost.
|
||||
#
|
||||
# We will send an email from A to C, and expect it to go through B.
|
||||
|
||||
mkdir -p .certs
|
||||
for i in A B C; do
|
||||
CONFDIR=${i} generate_certs_for srv-${i}
|
||||
CONFDIR=${i} add_user user${i}@srv-${i} user${i}
|
||||
mkdir -p .logs-${i}
|
||||
cp ${i}/certs/srv-${i}/fullchain.pem .certs/cert-${i}.pem
|
||||
done
|
||||
|
||||
# Make the servers trust each other.
|
||||
export SSL_CERT_DIR="$PWD/.certs/"
|
||||
|
||||
chasquid -v=2 --logfile=.logs-A/chasquid.log --config_dir=A \
|
||||
--testing__dns_addr=127.0.0.1:9053 &
|
||||
chasquid -v=2 --logfile=.logs-B/chasquid.log --config_dir=B \
|
||||
--testing__dns_addr=127.0.0.1:9053 \
|
||||
--testing__outgoing_smtp_port=3025 &
|
||||
chasquid -v=2 --logfile=.logs-C/chasquid.log --config_dir=C \
|
||||
--testing__dns_addr=127.0.0.1:9053 \
|
||||
--testing__outgoing_smtp_port=2025 &
|
||||
|
||||
wait_until_ready 1025
|
||||
wait_until_ready 2025
|
||||
wait_until_ready 3025
|
||||
|
||||
# Use A to send to C, and wait for delivery.
|
||||
run_msmtp userC@srv-c < content
|
||||
wait_for_file .mail/userc@srv-c
|
||||
mail_diff content .mail/userc@srv-c
|
||||
|
||||
# Check that it went through B.
|
||||
if ! grep -q "from=userA@srv-a to=userC@srv-c sent" .logs/mail_log-B; then
|
||||
fail "can't find record of delivery on the smarthost B"
|
||||
fi
|
||||
|
||||
success
|
||||
6
test/t-20-smarthost/zones
Normal file
6
test/t-20-smarthost/zones
Normal file
@@ -0,0 +1,6 @@
|
||||
srv-a A 127.0.0.1
|
||||
srv-a AAAA ::1
|
||||
srv-b A 127.0.0.1
|
||||
srv-b AAAA ::1
|
||||
srv-c A 127.0.0.1
|
||||
srv-c AAAA ::1
|
||||
Reference in New Issue
Block a user