Tags: patch

Hi,

Here's a patch to use sendmail directly, instead of relying on mailx.
sendmail -t should work with any decent MTA.

Greetings,
Bas.
diff --git a/debian/changelog b/debian/changelog
index 3a8cc38..71b18fa 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+cron-apt (0.9.6.bas) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * test sendmail  
+
+ -- Bas Zoetekouw <b...@debian.org>  Mon, 28 Nov 2016 11:03:16 +0100
+
 cron-apt (0.9.6) unstable; urgency=medium
 
   * Correction to make it work with space in XHEADERS. Closes: #813609.
diff --git a/debian/control b/debian/control
index f12fb70..4438d01 100644
--- a/debian/control
+++ b/debian/control
@@ -9,7 +9,7 @@ Standards-Version: 3.9.6
 Package: cron-apt
 Architecture: all
 Depends: apt, ${misc:Depends}
-Recommends: liblockfile1, mailx, cron | cron-daemon
+Recommends: liblockfile1, cron | cron-daemon, mail-transport-agent
 Description: automatic update of packages using apt-get
  Contains a tool that is run by a cron job at regular intervals. By default it
  just updates the package list and downloads new packages without installing.
diff --git a/src/functions b/src/functions
index 8ff2d74..4e3dcf0 100644
--- a/src/functions
+++ b/src/functions
@@ -94,27 +94,29 @@ onexit() {
        rm -f "$RUNMAIL"
     fi
     if [ -f "$MAIL" ] && [ "$MAILON" != "never" ] && [ -n "$MAILON" ] ; then
-       if command -v mail >/dev/null; then
+       if command -v sendmail >/dev/null; then
+           hdr="To: $MAILTO"
            if [ -z "$HOSTNAME" ]; then
                HOSTNAME="$(uname -n)"
            fi
-           SUBJECT="CRON-APT completed on $HOSTNAME [$CONFIG]"
            if [ -f "$ERROR" ] ; then
-               SUBJECT="CRON-APT error on $HOSTNAME [$CONFIG]"
+               hdr=$(printf "$hdr\nSubject: CRON-APT error on $HOSTNAME 
[$CONFIG]")
+           else
+               hdr=$(printf "$hdr\nSubject: CRON-APT completed on $HOSTNAME 
[$CONFIG]")
            fi
            # Support for XHEADERS
             i=1
            eval "VAL=\${XHEADER$i}"
            while [ ! -z "$VAL" ] ; do
-               XHEADERS="$XHEADERS -a \"$VAL\""
+               hdr=$(printf "$hdr\n$VAL")
                i=$(( $i + 1 ))
                eval "VAL=\${XHEADER$i}"
            done
            #
-            eval mail $XHEADERS -s \"$SUBJECT\" \"$MAILTO\" < "$MAIL"
+            ( printf "$hdr\n"; echo; cat $MAIL ) | sendmail -t
        else
-           echo >&2 "cron-apt was configured to send e-mail, but no mail 
binary found in path."
-           echo >&2 "Either set MAILON=never in configuration or install the 
mailx package."
+           echo >&2 "cron-apt was configured to send e-mail, but no sendmail 
binary was found in path."
+           echo >&2 "Either set MAILON=never in configuration or install an 
MTA package."
        fi
        rm -f "$MAIL"
     fi

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to