From 50c6c2c5d50ff8a6cfa9f5c33594b39e026d5ae9 Mon Sep 17 00:00:00 2001 From: zertrin Date: Wed, 18 May 2016 20:51:18 +0200 Subject: [PATCH] Add the possibility to give additional options to the mail command. Based on contribution from @f-andrey. --- duplicity-backup.conf.example | 9 +++++++++ duplicity-backup.sh | 1 + 2 files changed, 10 insertions(+) diff --git a/duplicity-backup.conf.example b/duplicity-backup.conf.example index 6911eec..4fef4e0 100644 --- a/duplicity-backup.conf.example +++ b/duplicity-backup.conf.example @@ -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" diff --git a/duplicity-backup.sh b/duplicity-backup.sh index 5e122b2..01489b4 100755 --- a/duplicity-backup.sh +++ b/duplicity-backup.sh @@ -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)