mirror of
https://github.com/docker-mailserver/docker-mailserver
synced 2026-08-05 10:32:59 +02:00
29 lines
744 B
Bash
Executable File
29 lines
744 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# shellcheck source=../scripts/helpers/index.sh
|
|
source /usr/local/bin/helpers/index.sh
|
|
|
|
set -o errexit
|
|
set -o pipefail
|
|
set -o nounset
|
|
|
|
HOSTNAME=${1}
|
|
RECIPIENT=${2}
|
|
SENDER=${3}
|
|
|
|
[[ -x /usr/sbin/pflogsumm ]] || _exit_with_error "'/usr/sbin/pflogsumm' not found or executable"
|
|
|
|
# `pflogsumm` expects files in chronological order, while for `-d yesterday`
|
|
# the only relevant log files to process are `mail.log.1` (oldest) and `mail.log`:
|
|
BODY=$(/usr/sbin/pflogsumm --problems_first -d yesterday /var/log/mail/mail.log{.1,})
|
|
|
|
sendmail -t <<EOF
|
|
From: ${SENDER}
|
|
To: ${RECIPIENT}
|
|
Subject: Postfix summary for ${HOSTNAME} sent $(date '+%Y-%m-%d_%H%M%S')
|
|
Content-Transfer-Encoding: 8bit
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
${BODY}
|
|
EOF
|