From 3a61ca32e6e32d965b760047aed44a1589e83a87 Mon Sep 17 00:00:00 2001
From: Julien Cristau <jcristau@debian.org>
Date: Wed, 13 Oct 2010 19:01:28 +0200
Subject: [PATCH] pts-subscribe: use sendmail directly instead of mail

Lets us control what headers are used.
---
 scripts/pts-subscribe.sh |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/scripts/pts-subscribe.sh b/scripts/pts-subscribe.sh
index 3a0e8c3..829f118 100755
--- a/scripts/pts-subscribe.sh
+++ b/scripts/pts-subscribe.sh
@@ -131,10 +131,10 @@ if [ $# -ne 1 ]; then
     exit 1
 fi
 
-# Check for a "mail" command
-if ! command -v mail >/dev/null 2>&1; then
-    echo "$PROGNAME: Could not find the \"mail\" command; you must have the" >&2
-    echo "bsd-mailx or mailutils package installed to run this script." >&2
+# Check for sendmail
+if ! [ -x /usr/sbin/sendmail ] >/dev/null 2>&1; then
+    echo "$PROGNAME: Could not find the \"sendmail\" command; you must have a" >&2
+    echo "MTA installed to run this script." >&2
     exit 1
 fi
 
@@ -151,7 +151,12 @@ fi
 DEBEMAIL=$(echo $DEBEMAIL | sed -s 's/^.*[ 	]<\(.*\)>.*/\1/')
 
 if [ "$ACTION" = "unsubscribe" ]; then
-    echo "$ACTION $pkg $DEBEMAIL" | mail pts@qa.debian.org
+    /usr/sbin/sendmail -t -oi << EOF
+From: $DEBEMAIL
+To: pts@qa.debian.org
+
+$ACTION $pkg $DEBEMAIL
+EOF
 else
     # Check for an "at" command
     if [ "$PTS_UNTIL" != forever ]; then
@@ -166,12 +171,23 @@ else
     if [ "$PTS_UNTIL" != forever ]; then
 	TEMPFILE=$(mktemp) || { echo "$PROGNAME: Couldn't create tempfile!" >&2; exit 1; }
 	trap "rm -f '$TEMPFILE'" 0 1 2 3 7 10 13 15
-	echo "echo 'unsubscribe $pkg $DEBEMAIL' | mail pts@qa.debian.org" | \
+	echo "/usr/sbin/sendmail -t -oi << EOF
+From: $DEBEMAIL
+To: pts@qa.debian.org
+
+unsubscribe $pkg $DEBEMAIL
+EOF
+	" | \
 	    at $PTS_UNTIL 2>$TEMPFILE
 	grep '^job ' $TEMPFILE | sed -e 's/^/Unsubscription will be sent by "at" as /'
     else
 	echo "No unsubscription request will be sent"
     fi
 
-    echo "$ACTION $pkg $DEBEMAIL" | mail pts@qa.debian.org
+    /usr/sbin/sendmail -t -oi << EOF
+From: $DEBEMAIL
+To: pts@qa.debian.org
+
+$ACTION $pkg $DEBEMAIL
+EOF
 fi
-- 
1.7.1

