prompt "ezmlm-send trailer:   "

echo "trailer is present" > "$DIR"/text/trailer
LOCAL="$LIST"

cat >"$TMP" <<EOF
From: test@example.org
Subject: test post

message goes here
EOF

touch "$DIR"/addtrailer
${EZBIN}/ezmlm-send "$DIR" <"$TMP" >"$ERR" 2>&1 || \
  fatal "failed to produce post"
grepbody trailer is present

rm "$DIR"/addtrailer
${EZBIN}/ezmlm-send "$DIR" <"$TMP" >"$ERR" 2>&1 || \
  fatal "failed to produce post"
grepbodynot trailer is present

# Check loading flags from "flags"

touch "$DIR"/addtrailer
echo aBcdefGHIJkLmNOpqRSTuvWxYz > "$DIR"/flags
${EZBIN}/ezmlm-send "$DIR" <"$TMP" >"$ERR" 2>&1 || \
  fatal "failed to produce post"
grepbodynot trailer is present

rm "$DIR"/addtrailer
echo aBcdefGHIJkLmNOpqRStuvWxYz > "$DIR"/flags
${EZBIN}/ezmlm-send "$DIR" <"$TMP" >"$ERR" 2>&1 || \
  fatal "failed to produce post"
grepbody trailer is present

rm "$DIR"/flags

touch "$DIR"/addtrailer
for encoding in 7bit base64 quoted-printable
do
  cat >"$TMP" <<EOF
From: test@example.org
Subject: test post
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: $encoding

bWVzc2FnZSBnb2VzIGhlcmUK
EOF
  ${EZBIN}/ezmlm-send "$DIR" <"$TMP" >"$ERR" 2>&1 || \
    fatal "failed to produce post"
  if [ "$encoding" = base64 ]; then
    grepbody DQp0cmFpbGVyIGlzIHByZXNlbnQNCg0K
  else
    grepbody 'trailer is present'
  fi
done

echo OK
