[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[msmtp-users] Forwarded patch to find_alias_for_msmtp.sh



Hi everyone,

attached is a patch by Alexandre de Verteuil that allows the
find_alias_for_msmtp.sh to be used with cronie.

If there are no objections, I will apply this patch soon.

Regards,
Martin
diff --git a/scripts/find_alias/find_alias_for_msmtp.sh b/scripts/find_alias/find_alias_for_msmtp.sh
index fb485dd..346f313 100644
--- a/scripts/find_alias/find_alias_for_msmtp.sh
+++ b/scripts/find_alias/find_alias_for_msmtp.sh
@@ -16,15 +16,18 @@ MSMTP=`which msmtp || echo "/usr/local/bin/msmtp"`
 #
 if [  "$1" = '-i'  ] ; then
    v_recipient=$2 # mailx calls sendmail with -i as the 1st param and the recipient as the second param
-elif [ "$1" = '-t' ] ; then  # most other programs call sendmail with a -t option
+elif [ "$1" = '-t' -o $# = 0 ] ; then  
+        # Most other programs call sendmail with a -t option.
+        # cronie calls sendmail without parameters and
+        # expects sendmail to find the recipient in the mail headers.
         v_to=`echo "$v_msg" | grep -m 1 'To: '`
         v_recipient=${v_to:4:50}
 else
-   v_recipient=$1 # no parameter, sendmail was called with the recipient as parameter
+   v_recipient=$1 # sendmail was called with the recipient as parameter
 fi
 #
 
-if [ $v_recipient != 0 ] ; then
+if [ "$v_recipient" != 0 ] ; then
 
 # trim spaces from recipient email address
  v_recipient="${v_recipient// /}"