chiark / gitweb /
mail: Send mail with the correct envelope sender. master
authorMark Wooding <mdw@distorted.org.uk>
Thu, 25 Jan 2007 12:59:07 +0000 (12:59 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 25 Jan 2007 12:59:07 +0000 (12:59 +0000)
bin/mail
defs

index 6ef138d..afcc0d8 100755 (executable)
--- a/bin/mail
+++ b/bin/mail
@@ -12,4 +12,4 @@ set -- $entry
   sed -n ":top; /^$/,\$ b ok
           /^[Tt][Oo]: / ! b ok; :loop; n; /^ / b loop; b top
           :ok; p"; } |
-qmail-inject -a -f$USER-$1@`cat $QMAIL/control/me` $3
+qmail-inject -a -f$USER-$1@$(control defaulthost "$me") $3
diff --git a/defs b/defs
index b7ac630..52e7f25 100644 (file)
--- a/defs
+++ b/defs
@@ -7,6 +7,17 @@ QMAIL=/var/qmail
 PATH=$NEWS/bin:$QMAIL/bin:$HOME/bin:$PATH
 export PATH
 
-bad () { echo >&2 "newsgate: fatal: $@"; exit 100; }
-fail () { echo >&2 "newsgate: $@"; exit 111; }
+bad () { echo >&2 "newsgate: fatal: $*"; exit 100; }
+fail () { echo >&2 "newsgate: $*"; exit 111; }
 
+control () {
+  if [ -r $QMAIL/control/$1 ]; then
+    cat $QMAIL/control/$1
+  elif [ "${2+yes}" ]; then
+    echo "$2"
+  else
+    bad "control $1 not found"
+  fi
+}
+
+me=$(control me)