Add the possibility to give additional options to the mail command. Based on contribution from @f-andrey.

This commit is contained in:
zertrin 2016-05-18 20:51:18 +02:00
parent dcdc081f30
commit 50c6c2c5d5
2 changed files with 10 additions and 0 deletions

View file

@ -387,12 +387,21 @@ EMAIL_SUBJECT=
EMAIL_FAILURE_ONLY="yes" # send e-mail only if there was an error while creating backup
# command to use to send mail
# don't put any options here, as ${MAIL} is used to check if the command is available
# on the system and locate its binary
MAIL="mailx" # default command for Linux mail
#MAIL="mail" # for CentOS, if "mailx" fails try this one
#MAIL="ssmtp"
#MAIL="sendmail"
#MAIL="msmtp"
# Array to pass additional options to the mail command
# the options will be passed immediately after the name of the mail command
# like this: ${MAIL} ${MAIL_OPTIONS[*]} ${other options}
MAIL_OPTIONS=()
# for example with mailx, you can set the server and port for sending mails like this
#MAIL_OPTIONS=(-S smtp="smtps://mailserver.example.com:587")
# You may specify a custom mail script instead. It will be called with
# the following convention:
# MAIL "SUBJECT OF MESSAGE" "TO EMAIL ADDRESS" "FROM EMAIL ADDRESS"

View file

@ -375,6 +375,7 @@ email_logfile()
if [ ! -x "${MAILCMD}" ]; then
echo -e "Email couldn't be sent. ${MAIL} not available." >> "${LOGFILE}"
else
MAILCMD="${MAILCMD} ${MAIL_OPTIONS[*]}"
EMAIL_SUBJECT=${EMAIL_SUBJECT:="duplicity-backup ${BACKUP_STATUS:-"ERROR"} [${HOSTNAME}] ${LOG_FILE}"}
case ${MAIL} in
ssmtp)