s4

changeset 661:14a7c23f3f06

Allow supplemental rcpt address and file attachment in DM in grpAction
author HIROSE Yuuji <yuuji@gentei.org>
date Mon, 11 May 2020 23:03:11 +0900
parents 347ea2bca687
children 3acb3dca6686
files s4-funcs.sh sendmultipart.sh
diffstat 2 files changed, 34 insertions(+), 10 deletions(-) [+]
line diff
     1.1 --- a/s4-funcs.sh	Mon May 11 23:01:19 2020 +0900
     1.2 +++ b/s4-funcs.sh	Mon May 11 23:03:11 2020 +0900
     1.3 @@ -2662,11 +2662,27 @@
     1.4  	  checkdomain "$a" && supprcpt="$supprcpt $a"
     1.5  	done
     1.6        fi
     1.7 +      ## Start parse of attachment files
     1.8 +      if [ -n `getpar attach` ]; then
     1.9 +	afiles=""
    1.10 +	for fn in `query "SELECT DISTINCT val FROM par WHERE var='files';"`
    1.11 +	do
    1.12 +	  f=$tmpd/$fn
    1.13 +	  if [ -s $f ]; then
    1.14 +	    afiles=$afiles"${afiles:+ }$f"
    1.15 +	  fi
    1.16 +	done
    1.17 +      fi
    1.18        ## SENDER=$noreply \ # Should not SENDER be set to $noreply??
    1.19 -      REPLYTO=$replyto \
    1.20 -      MAIL_FROM=$mail_from \
    1.21 -	       smail "`email4groupbyuid "$grp" $usel` $user$supprcpt" \
    1.22 -	       "$gecos さんからのメッセージ" <<EOF
    1.23 +      rcpts="`email4groupbyuid "$grp" $usel` $user$supprcpt"
    1.24 +      subj="$gecos さんからのメッセージ"
    1.25 +      REPLYTO=$replyto
    1.26 +      MAIL_FROM=$mail_from
    1.27 +      if [ -n "$afiles" ];then
    1.28 +	./sendmultipart.sh -t "$rcpts" -s "$subj" -f "$mail_from" $afiles
    1.29 +      else
    1.30 +	smail "$rcpts" $subj 
    1.31 +      fi <<EOF
    1.32  $url
    1.33  のグループ「$grp」のメンバーである $gecos さんから、
    1.34  あなた宛へのメッセージです。
    1.35 @@ -2822,8 +2838,12 @@
    1.36  >差出人を自分に(チェックを外すと相手が返事できない)</label><br>
    1.37  <input type="checkbox" name="suppck" id="supp" class="fold"><label for="supp"
    1.38  >宛先追加(通常空欄)</label>
    1.39 -<span class="folded">`cgi_text supprcpt`(下記一覧の1人以上選択しないと無効)</span>
    1.40 +<span class="folded">`cgi_text supprcpt`[実験中](下記一覧の1人以上選択しないと無効)</span>
    1.41  <div>`cgi_textarea text "" cols=40`</div>
    1.42 +
    1.43 +<input type="checkbox" name="attach" id="atta" class="fold"><label for="atta"
    1.44 +>ファイル添付</label>
    1.45 +<span class="folded">`cgi_file files "" multiple`[実験中]</span>
    1.46  </div>
    1.47  ${isowner:+$cmmsg$excmsg}
    1.48  `cgi_radio rm close id="x"`<label for="x">×</label>
     2.1 --- a/sendmultipart.sh	Mon May 11 23:01:19 2020 +0900
     2.2 +++ b/sendmultipart.sh	Mon May 11 23:03:11 2020 +0900
     2.3 @@ -1,9 +1,10 @@
     2.4  #!/bin/sh
     2.5 +# 愛
     2.6  # send multipart message via email
     2.7  # (C)2012,2015 by HIROSE Yuuji [yuuji(at)yatex.org]
     2.8  # You can obtain the latest version of this script from:
     2.9  #   http://www.gentei.org/~yuuji/software/sendmultipart.sh
    2.10 -# Last modified Sat May  9 13:09:42 2020 on firestorm
    2.11 +# Last modified Mon May 11 21:42:39 2020 on firestorm
    2.12  #
    2.13  # Typical usage:
    2.14  #  echo "Hi, here's photo I've taken.  Enjoy" | \
    2.15 @@ -38,7 +39,9 @@
    2.16   boundary=\"$boundary\""
    2.17  textcharset=iso-2022-jp
    2.18  rcpts=""
    2.19 -rcptscomma=""
    2.20 +nl="
    2.21 +"
    2.22 +rcptheader=""
    2.23  
    2.24  [ -f $conf ] && . $conf		# read rc file
    2.25  
    2.26 @@ -46,9 +49,9 @@
    2.27    case "$1" in
    2.28      -t)	shift;
    2.29        rcpts="$rcpts${rcpts:+ }`echo $1|tr , ' '`"
    2.30 -      rcptscomma="$rcptscomma${rcptscomma:+, }$1"
    2.31        ;;
    2.32      -s) shift; subject="`echo $1|nkf -M`" ;;
    2.33 +    -r) shift; REPLYTO="$1" ;;
    2.34      -f) shift; from="From: $1" ;;
    2.35      -v)	verbose=1 ;;
    2.36      -h) usage ;;		# -h helpオプション
    2.37 @@ -57,6 +60,7 @@
    2.38    esac
    2.39    shift	
    2.40  done
    2.41 +rcptheader=`echo $rcpts|tr ' ' '\n'|sort -u|sed 's/^/To: /g'`
    2.42  plainheader="Content-Type: text/plain; charset=$textcharset
    2.43  Content-Transfer-Encoding: 7bit"
    2.44  
    2.45 @@ -89,8 +93,8 @@
    2.46  
    2.47  # Generate contents
    2.48  ( cat<<EOF
    2.49 -To: ${rcptscomma:-[Not specified]}
    2.50 -Subject: ${subject:-$*}
    2.51 +${rcptheader:-To: [Not specified]}
    2.52 +${REPLYTO:+Reply-to: $REPLYTO$nl}Subject: ${subject:-$*}
    2.53  $ctheader
    2.54  Mime-Version: 1.0
    2.55  X-Mailer: $mailer