mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
Report sender (#965)
* added REPORT_SENDER env variable to the container. * integration test for REPORT_SENDER * added tests for default REPORT_SENDER
This commit is contained in:
parent
c1118af66d
commit
60656aec49
|
@ -107,6 +107,12 @@ POSTFIX_DAGENT=
|
||||||
# => Specify the recipient address
|
# => Specify the recipient address
|
||||||
REPORT_RECIPIENT=0
|
REPORT_RECIPIENT=0
|
||||||
|
|
||||||
|
|
||||||
|
# Change the sending address for mail report
|
||||||
|
# **empty** => mailserver-report@hostname
|
||||||
|
# => Specify the report sender (From) address
|
||||||
|
REPORT_SENDER=
|
||||||
|
|
||||||
# Changes the interval in which a report is being sent.
|
# Changes the interval in which a report is being sent.
|
||||||
# **daily** => Send a daily report
|
# **daily** => Send a daily report
|
||||||
# weekly => Send a report every week
|
# weekly => Send a report every week
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -35,6 +35,7 @@ run:
|
||||||
-e SPOOF_PROTECTION=1 \
|
-e SPOOF_PROTECTION=1 \
|
||||||
-e ENABLE_SPAMASSASSIN=1 \
|
-e ENABLE_SPAMASSASSIN=1 \
|
||||||
-e REPORT_RECIPIENT=user1@localhost.localdomain \
|
-e REPORT_RECIPIENT=user1@localhost.localdomain \
|
||||||
|
-e REPORT_SENDER=report1@mail.my-domain.com \
|
||||||
-e SA_TAG=-5.0 \
|
-e SA_TAG=-5.0 \
|
||||||
-e SA_TAG2=2.0 \
|
-e SA_TAG2=2.0 \
|
||||||
-e SA_KILL=3.0 \
|
-e SA_KILL=3.0 \
|
||||||
|
@ -153,6 +154,7 @@ run:
|
||||||
-e DOVECOT_TLS=no \
|
-e DOVECOT_TLS=no \
|
||||||
-e DOVECOT_PASS_FILTER="(&(objectClass=PostfixBookMailAccount)(uniqueIdentifier=%n))" \
|
-e DOVECOT_PASS_FILTER="(&(objectClass=PostfixBookMailAccount)(uniqueIdentifier=%n))" \
|
||||||
-e DOVECOT_USER_FILTER="(&(objectClass=PostfixBookMailAccount)(uniqueIdentifier=%n))" \
|
-e DOVECOT_USER_FILTER="(&(objectClass=PostfixBookMailAccount)(uniqueIdentifier=%n))" \
|
||||||
|
-e REPORT_RECIPIENT=1 \
|
||||||
-e ENABLE_SASLAUTHD=1 \
|
-e ENABLE_SASLAUTHD=1 \
|
||||||
-e SASLAUTHD_MECHANISMS=ldap \
|
-e SASLAUTHD_MECHANISMS=ldap \
|
||||||
-e SASLAUTHD_LDAP_SERVER=ldap \
|
-e SASLAUTHD_LDAP_SERVER=ldap \
|
||||||
|
|
|
@ -314,12 +314,14 @@ Enabled by ENABLE_POSTFIX_VIRTUAL_TRANSPORT. Specify the final delivery of postf
|
||||||
- **empty** => postmaster@domain.com
|
- **empty** => postmaster@domain.com
|
||||||
- => Specify the postmaster address
|
- => Specify the postmaster address
|
||||||
|
|
||||||
|
|
||||||
##### POSTSCREEN_ACTION
|
##### POSTSCREEN_ACTION
|
||||||
|
|
||||||
- **enforce** => Allow other tests to complete. Reject attempts to deliver mail with a 550 SMTP reply, and log the helo/sender/recipient information. Repeat this test the next time the client connects.
|
- **enforce** => Allow other tests to complete. Reject attempts to deliver mail with a 550 SMTP reply, and log the helo/sender/recipient information. Repeat this test the next time the client connects.
|
||||||
- drop => Drop the connection immediately with a 521 SMTP reply. Repeat this test the next time the client connects.
|
- drop => Drop the connection immediately with a 521 SMTP reply. Repeat this test the next time the client connects.
|
||||||
- ignore => Ignore the failure of this test. Allow other tests to complete. Repeat this test the next time the client connects. This option is useful for testing and collecting statistics without blocking mail.
|
- ignore => Ignore the failure of this test. Allow other tests to complete. Repeat this test the next time the client connects. This option is useful for testing and collecting statistics without blocking mail.
|
||||||
|
|
||||||
|
|
||||||
##### REPORT_RECIPIENT
|
##### REPORT_RECIPIENT
|
||||||
|
|
||||||
Enables a report being sent (created by pflogsumm) on a regular basis.
|
Enables a report being sent (created by pflogsumm) on a regular basis.
|
||||||
|
@ -327,6 +329,13 @@ Enabled by ENABLE_POSTFIX_VIRTUAL_TRANSPORT. Specify the final delivery of postf
|
||||||
- 1 => Using POSTMASTER_ADDRESS as the recipient
|
- 1 => Using POSTMASTER_ADDRESS as the recipient
|
||||||
- => Specify the recipient address
|
- => Specify the recipient address
|
||||||
|
|
||||||
|
##### REPORT_SENDER
|
||||||
|
|
||||||
|
Change the sending address for mail report
|
||||||
|
- **empty** => mailserver-report@hostname
|
||||||
|
- => Specify the report sender (From) address
|
||||||
|
|
||||||
|
|
||||||
##### REPORT_INTERVAL
|
##### REPORT_INTERVAL
|
||||||
|
|
||||||
changes the interval in which a report is being sent.
|
changes the interval in which a report is being sent.
|
||||||
|
|
|
@ -28,6 +28,7 @@ services:
|
||||||
- POSTSCREEN_ACTION=${POSTSCREEN_ACTION}
|
- POSTSCREEN_ACTION=${POSTSCREEN_ACTION}
|
||||||
- ENABLE_SRS=${ENABLE_SRS}
|
- ENABLE_SRS=${ENABLE_SRS}
|
||||||
- REPORT_RECIPIENT=${REPORT_RECIPIENT}
|
- REPORT_RECIPIENT=${REPORT_RECIPIENT}
|
||||||
|
- REPORT_SENDER=${REPORT_SENDER}
|
||||||
- REPORT_INTERVAL=${REPORT_INTERVAL}
|
- REPORT_INTERVAL=${REPORT_INTERVAL}
|
||||||
- SMTP_ONLY=${SMTP_ONLY}
|
- SMTP_ONLY=${SMTP_ONLY}
|
||||||
- SSL_TYPE=${SSL_TYPE}
|
- SSL_TYPE=${SSL_TYPE}
|
||||||
|
|
|
@ -25,6 +25,7 @@ services:
|
||||||
- POSTMASTER_ADDRESS=${POSTMASTER_ADDRESS}
|
- POSTMASTER_ADDRESS=${POSTMASTER_ADDRESS}
|
||||||
- POSTSCREEN_ACTION=${POSTSCREEN_ACTION}
|
- POSTSCREEN_ACTION=${POSTSCREEN_ACTION}
|
||||||
- REPORT_RECIPIENT=${REPORT_RECIPIENT}
|
- REPORT_RECIPIENT=${REPORT_RECIPIENT}
|
||||||
|
- REPORT_SENDER=${REPORT_SENDER}
|
||||||
- REPORT_INTERVAL=${REPORT_INTERVAL}
|
- REPORT_INTERVAL=${REPORT_INTERVAL}
|
||||||
- SMTP_ONLY=${SMTP_ONLY}
|
- SMTP_ONLY=${SMTP_ONLY}
|
||||||
- SSL_TYPE=${SSL_TYPE}
|
- SSL_TYPE=${SSL_TYPE}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
HOSTNAME=$1
|
HOSTNAME=$1
|
||||||
RECIPIENT=$2
|
RECIPIENT=$2
|
||||||
|
SENDER=$3
|
||||||
errex() {
|
errex() {
|
||||||
echo -e "$@" 1>&2
|
echo -e "$@" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -23,7 +23,7 @@ The $HOSTNAME Mailserver"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sendmail -t <<EOF
|
sendmail -t <<EOF
|
||||||
From: mailserver-report@$HOSTNAME
|
From: $SENDER
|
||||||
To: $RECIPIENT
|
To: $RECIPIENT
|
||||||
Subject: Postfix Summary for $HOSTNAME
|
Subject: Postfix Summary for $HOSTNAME
|
||||||
Content-Transfer-Encoding: 8bit
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
|
@ -417,6 +417,8 @@ function _setup_default_vars() {
|
||||||
|
|
||||||
# update POSTMASTER_ADDRESS - must be done done after _check_hostname()
|
# update POSTMASTER_ADDRESS - must be done done after _check_hostname()
|
||||||
DEFAULT_VARS["POSTMASTER_ADDRESS"]="${POSTMASTER_ADDRESS:=postmaster@${DOMAINNAME}}"
|
DEFAULT_VARS["POSTMASTER_ADDRESS"]="${POSTMASTER_ADDRESS:=postmaster@${DOMAINNAME}}"
|
||||||
|
# update REPORT_SENDER - must be done done after _check_hostname()
|
||||||
|
DEFAULT_VARS["REPORT_SENDER"]="${REPORT_SENDER:=mailserver-report@${HOSTNAME}}"
|
||||||
|
|
||||||
for var in ${!DEFAULT_VARS[@]}; do
|
for var in ${!DEFAULT_VARS[@]}; do
|
||||||
echo "export $var=${DEFAULT_VARS[$var]}" >> /root/.bashrc
|
echo "export $var=${DEFAULT_VARS[$var]}" >> /root/.bashrc
|
||||||
|
@ -1234,7 +1236,8 @@ function _setup_logrotate() {
|
||||||
function _setup_mail_summary() {
|
function _setup_mail_summary() {
|
||||||
notify 'inf' "Enable postfix summary with recipient $REPORT_RECIPIENT"
|
notify 'inf' "Enable postfix summary with recipient $REPORT_RECIPIENT"
|
||||||
[ "$REPORT_RECIPIENT" = 1 ] && REPORT_RECIPIENT=$POSTMASTER_ADDRESS
|
[ "$REPORT_RECIPIENT" = 1 ] && REPORT_RECIPIENT=$POSTMASTER_ADDRESS
|
||||||
sed -i "s|}| postrotate\n /usr/local/bin/postfix-summary $HOSTNAME $REPORT_RECIPIENT\n endscript\n}\n|" /etc/logrotate.d/maillog
|
sed -i "s|}| postrotate\n /usr/local/bin/postfix-summary $HOSTNAME \
|
||||||
|
$REPORT_RECIPIENT $REPORT_SENDER\n endscript\n}\n|" /etc/logrotate.d/maillog
|
||||||
}
|
}
|
||||||
|
|
||||||
function _setup_environment() {
|
function _setup_environment() {
|
||||||
|
|
|
@ -1596,6 +1596,16 @@ load 'test_helper/bats-assert/load'
|
||||||
sleep 10
|
sleep 10
|
||||||
run docker exec mail grep "Subject: Postfix Summary for " /var/mail/localhost.localdomain/user1/new/ -R
|
run docker exec mail grep "Subject: Postfix Summary for " /var/mail/localhost.localdomain/user1/new/ -R
|
||||||
assert_success
|
assert_success
|
||||||
|
# check sender is the one specified in REPORT_SENDER
|
||||||
|
run docker exec mail grep "From: report1@mail.my-domain.com" /var/mail/localhost.localdomain/user1/new/ -R
|
||||||
|
assert_success
|
||||||
|
# check sender is not the default one.
|
||||||
|
run docker exec mail grep "From: mailserver-report@mail.my-domain.com" /var/mail/localhost.localdomain/user1/new/ -R
|
||||||
|
assert_failure
|
||||||
|
|
||||||
|
# checking default sender is correctly set when env variable not defined
|
||||||
|
run docker exec mail_with_ldap grep "mailserver-report@mail.my-domain.com" /etc/logrotate.d/maillog
|
||||||
|
assert_success
|
||||||
# checking default logrotation setup
|
# checking default logrotation setup
|
||||||
run docker exec mail_with_ldap grep "daily" /etc/logrotate.d/maillog
|
run docker exec mail_with_ldap grep "daily" /etc/logrotate.d/maillog
|
||||||
assert_success
|
assert_success
|
||||||
|
|
Loading…
Reference in a new issue