public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
Only sent mail if enabled
fe8131f7
data/Dockerfiles/watchdog/watchdog.sh | 61 ++++++++++++++++++-----------------
1 file changed, 32 insertions(+), 29 deletions(-)
Diff
diff --git a/data/Dockerfiles/watchdog/watchdog.sh b/data/Dockerfiles/watchdog/watchdog.sh
index e6e70ba7..5d962309 100755
--- a/data/Dockerfiles/watchdog/watchdog.sh
+++ b/data/Dockerfiles/watchdog/watchdog.sh
@@ -124,37 +124,40 @@ function notify_error() {
else
SUBJECT="${WATCHDOG_SUBJECT}: ${1}"
fi
- IFS=',' read -r -a MAIL_RCPTS <<< "${WATCHDOG_NOTIFY_EMAIL}"
- for rcpt in "${MAIL_RCPTS[@]}"; do
- RCPT_DOMAIN=
- RCPT_MX=
- RCPT_DOMAIN=$(echo ${rcpt} | awk -F @ {'print $NF'})
- CHECK_FOR_VALID_MX=$(dig +short ${RCPT_DOMAIN} mx)
- if [[ -z ${CHECK_FOR_VALID_MX} ]]; then
- log_msg "Cannot determine MX for ${rcpt}, skipping email notification..."
- return 1
- fi
- [ -f "/tmp/${1}" ] && BODY="/tmp/${1}"
- timeout 10s ./smtp-cli --missing-modules-ok \
- "${SMTP_VERBOSE}" \
- --charset=UTF-8 \
- --subject="${SUBJECT}" \
- --body-plain="${BODY}" \
- --add-header="X-Priority: 1" \
- --to=${rcpt} \
- --from="watchdog@${MAILCOW_HOSTNAME}" \
- --hello-host=${MAILCOW_HOSTNAME} \
- --ipv4
- if [[ $? -eq 1 ]]; then # exit code 1 is fine
- log_msg "Sent notification email to ${rcpt}"
- else
- if [[ "${SMTP_VERBOSE}" == "" ]]; then
- log_msg "Error while sending notification email to ${rcpt}. You can enable verbose logging by setting 'WATCHDOG_VERBOSE=y' in mailcow.conf."
+
+ if [[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]]; then
+ IFS=',' read -r -a MAIL_RCPTS <<< "${WATCHDOG_NOTIFY_EMAIL}"
+ for rcpt in "${MAIL_RCPTS[@]}"; do
+ RCPT_DOMAIN=
+ RCPT_MX=
+ RCPT_DOMAIN=$(echo ${rcpt} | awk -F @ {'print $NF'})
+ CHECK_FOR_VALID_MX=$(dig +short ${RCPT_DOMAIN} mx)
+ if [[ -z ${CHECK_FOR_VALID_MX} ]]; then
+ log_msg "Cannot determine MX for ${rcpt}, skipping email notification..."
+ return 1
+ fi
+ [ -f "/tmp/${1}" ] && BODY="/tmp/${1}"
+ timeout 10s ./smtp-cli --missing-modules-ok \
+ "${SMTP_VERBOSE}" \
+ --charset=UTF-8 \
+ --subject="${SUBJECT}" \
+ --body-plain="${BODY}" \
+ --add-header="X-Priority: 1" \
+ --to=${rcpt} \
+ --from="watchdog@${MAILCOW_HOSTNAME}" \
+ --hello-host=${MAILCOW_HOSTNAME} \
+ --ipv4
+ if [[ $? -eq 1 ]]; then # exit code 1 is fine
+ log_msg "Sent notification email to ${rcpt}"
else
- log_msg "Error while sending notification email to ${rcpt}."
+ if [[ "${SMTP_VERBOSE}" == "" ]]; then
+ log_msg "Error while sending notification email to ${rcpt}. You can enable verbose logging by setting 'WATCHDOG_VERBOSE=y' in mailcow.conf."
+ else
+ log_msg "Error while sending notification email to ${rcpt}."
+ fi
fi
- fi
- done
+ done
+ fi
}
get_container_ip() {