duplicity-backup.sh icon indicating copy to clipboard operation
duplicity-backup.sh copied to clipboard

Issues with email notifications - subject and to fields

Open AshleyHow opened this issue 7 years ago • 7 comments

Using CentOS7 I've found that when using the master branch any email notification sent have issues for me. Below is settings taken from config.

#EMAIL_TO="[email protected]" EMAIL_TO="[email protected]" EMAIL_FROM= EMAIL_SUBJECT="DML Backup Log" EMAIL_FAILURE_ONLY="no" # send e-mail only if there was an error while creating backup

#command to use to send mail MAIL="mailx" # default command for Linux mail #MAIL="mail" # for CentOS, if "mailx" fails try this one #MAIL="ssmtp" #MAIL="sendmail" #MAIL="msmtp"

Using mailx has the following behaviour. Mails received do not contain any subject, nor any backup status and a separate email is sent to [email protected], [email protected] and [email protected] in addition to [email protected].

Commented mailx and uncommented mail and tried again to get the same behaviour.

Using sendmail the to field seems to work as expected now and contains the subject but does not include the backup status in subject.

This is the same in dev branch. Issue not present in stable branch.

Is this intended, am I doing something wrong or is it a bug?

Thanks.

AshleyHow avatar Sep 24 '17 23:09 AshleyHow

Thanks for your feedback. I have never used CentOS so I'm not sure what's happening here.

The first thing to do would be identify exactly which package provides the mailx, mail, and sendmail commands on you system. There are a variety of mail clients that provide the same command and each of them have different options and expectations about their arguments.

For this my google-fu suggest something like rpm -qf myfilename where myfilename would be the result of running which <mailcommand> for <mailcommand> in mailx, mail and sendmail.

Please update with the results to understand better what is going on here.

zertrin avatar Sep 30 '17 15:09 zertrin

Thank for you for help on this.

Both mailx and mail use mailx-12.5-16.el7.x86_64 with sendmail using postfix-2.10.1-6.el7.x86_64

Hope this helps you.

AshleyHow avatar Sep 30 '17 18:09 AshleyHow

Does it work if you run echo "test 11" | mailx -s "test email 1" [email protected] on the command line manually? This should send a mail with the subject "test email 1" to [email protected] (please use your email address there). If this does not work, then mailx is not setup to send emails properly...

xmatthias avatar Nov 01 '17 08:11 xmatthias

Running that command works absolutely fine.

AshleyHow avatar Nov 27 '17 21:11 AshleyHow

HI - I've been testing this on Centos7. The problem is the case statement against ${MAIL} on line 536 of current master duplicity-backup.sh Centos7 uses heirloom mailx but the value of MAILCMD_BASENAME is set to just 'mailx' whereas the case statement expects 'heirloom-mailx', therefore the case statement is dropping through to mailcmd_else and being called incorrectly. If I edit the case statement at line 545 to just state mailx instead of heirloom-mailx, the correct format of mailx is called and the email comes through correctly with the subject, from and to parts of the mail set as expected. I'd be happy to submit a pull request with this but I'm not sure if this would break anything else. Maybe a heirloom-mailx|mailx) on line 545 would add the expected behaviour without breaking any previous behaviour where this was working correctly - if it indeed was for anyone using mailx on centos!

trilitheus avatar May 02 '18 14:05 trilitheus

I have very similar problem on Ubuntu. It started after recent update:

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

  [email protected]
    Unrouteable address
  [email protected]
    Unrouteable address

[-- #2 12/239 message/delivery-status, 7bit, US-ASCII --]


[-- #3 66/2595 message/rfc822 --]

Date: Wed, 06 Jun 2018 12:27:38 +0000
To: [email protected], [email protected], [email protected], [email protected]
Message-Id: <[email protected]>
From: Non-root User <[email protected]>

The correct address is among the ones it tries to send to but From is incorrect, Subject is missing, and the three additional addresses are who knows where from...

Switching branches from stable to master made the problem disappear.

silverdr avatar Jun 06 '18 12:06 silverdr

I'm running CentOS 8 and am using Postfix MTA. I can easily send a command using mail or mailx at the command line but when the script does it, I have the same issue as everyone else as outlined by this parent issue (e.g. no subject and multiple invalid TO: addresses).

The fix for me was to change the mail command in the config file to sendmail. It worked after that. However, if you aren't using Postfix MTA then you may have different results.

danieleagle avatar Apr 28 '20 01:04 danieleagle