mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
maillog: Support logging to stdout and stderr
This patch adds support for writing maillog to stdout and stderr, which can be desirable in certain environments. Thanks to Denys Vitali <denys@denv.it> who sent an alternative patch for this functionality.
This commit is contained in:
1
test/t-17-maillog/.gitignore
vendored
Normal file
1
test/t-17-maillog/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
config/chasquid.conf
|
||||
10
test/t-17-maillog/config/chasquid.conf.in
Normal file
10
test/t-17-maillog/config/chasquid.conf.in
Normal file
@@ -0,0 +1,10 @@
|
||||
smtp_address: ":1025"
|
||||
submission_address: ":1587"
|
||||
submission_over_tls_address: ":1465"
|
||||
monitoring_address: ":1099"
|
||||
|
||||
mail_delivery_agent_bin: "test-mda"
|
||||
mail_delivery_agent_args: "%to%"
|
||||
|
||||
data_dir: "../.data"
|
||||
mail_log_path: "$MAIL_LOG_PATH"
|
||||
4
test/t-17-maillog/content
Normal file
4
test/t-17-maillog/content
Normal file
@@ -0,0 +1,4 @@
|
||||
Subject: Prueba desde el test
|
||||
|
||||
Crece desde el test el futuro
|
||||
Crece desde el test
|
||||
1
test/t-17-maillog/hosts
Normal file
1
test/t-17-maillog/hosts
Normal file
@@ -0,0 +1 @@
|
||||
testserver localhost
|
||||
28
test/t-17-maillog/msmtprc
Normal file
28
test/t-17-maillog/msmtprc
Normal file
@@ -0,0 +1,28 @@
|
||||
account default
|
||||
|
||||
host testserver
|
||||
port 1587
|
||||
|
||||
tls on
|
||||
tls_trust_file config/certs/testserver/fullchain.pem
|
||||
|
||||
from user@testserver
|
||||
|
||||
auth on
|
||||
user user@testserver
|
||||
password secretpassword
|
||||
|
||||
account smtpport : default
|
||||
port 1025
|
||||
|
||||
account subm_tls : default
|
||||
port 1465
|
||||
tls_starttls off
|
||||
|
||||
account baduser : default
|
||||
user unknownuser@testserver
|
||||
password secretpassword
|
||||
|
||||
account badpasswd : default
|
||||
user user@testserver
|
||||
password badsecretpassword
|
||||
48
test/t-17-maillog/run.sh
Executable file
48
test/t-17-maillog/run.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
. $(dirname ${0})/../util/lib.sh
|
||||
|
||||
init
|
||||
|
||||
mkdir -p .logs
|
||||
|
||||
generate_certs_for testserver
|
||||
add_user user@testserver secretpassword
|
||||
add_user someone@testserver secretpassword
|
||||
|
||||
function send_one() {
|
||||
rm -f .logs/mail_log .logs/stdout .logs/stderr
|
||||
envsubst < config/chasquid.conf.in > config/chasquid.conf
|
||||
|
||||
chasquid -v=2 --logfile=.logs/chasquid.log --config_dir=config \
|
||||
> .logs/stdout 2> .logs/stderr &
|
||||
wait_until_ready 1025
|
||||
|
||||
run_msmtp someone@testserver < content
|
||||
wait_for_file .mail/someone@testserver
|
||||
mail_diff content .mail/someone@testserver
|
||||
|
||||
pkill -s 0 chasquid
|
||||
sleep 0.2
|
||||
}
|
||||
|
||||
export MAIL_LOG_PATH="../.logs/mail_log"
|
||||
send_one
|
||||
if ! grep -q "from=user@testserver all done" .logs/mail_log; then
|
||||
fail "entries not found in .logs/mail_log"
|
||||
fi
|
||||
|
||||
export MAIL_LOG_PATH="<stdout>"
|
||||
send_one
|
||||
if ! grep -q "from=user@testserver all done" .logs/stdout; then
|
||||
fail "entries not found in .logs/stdout"
|
||||
fi
|
||||
|
||||
export MAIL_LOG_PATH="<stderr>"
|
||||
send_one
|
||||
if ! grep -q "from=user@testserver all done" .logs/stderr; then
|
||||
fail "entries not found in .logs/stderr"
|
||||
fi
|
||||
|
||||
success
|
||||
Reference in New Issue
Block a user