+cat > "$MH_TEST_DIR/Mail/rcvdistcomps" <<'EOF'
+%(lit)%(formataddr{addresses})\
+%<(nonnull)%(void(width))%(putaddr Resent-To:)%>
+%(lit)%(formataddr{to})\
+%<(nonnull)%(void(width))%(putaddr Resent-From:)\n%>
+EOF
+
+# Set this for the EHLO command
+echo "clientname: nosuchhost.example.com" >> ${MHMTSCONF}
+
+# $1: message draft file
+# $2: output filename for fakesmtp, i.e., the sent message
+test_post ()
+{
+ pid=`"${MH_OBJ_DIR}/test/fakesmtp" "$2" $localport`
+
+ run_prog $rcvdist -form "$MH_TEST_DIR/Mail/rcvdistcomps" -server 127.0.0.1 -port $localport somebody@example.com <$1
+
+ sed -e 's/^Date:.*/Date:/' -e 's/^Resent-Date:.*/Resent-Date:/' "$2" > "$2".nodate
+ rm -f "$2"
+
+ check "$2".nodate "$3"
+}
+
+test_post "${MH_TEST_DIR}/Mail/draft" "${testname}.fakesmtp" "${testname}.expected"
+
+#### Use sendmail/pipe below to override default mts.
+mts_fakesendmail="${MHMTSCONF}-fakesendmail"
+sed -e 's/^mts:.*/mts: sendmail\/pipe/' "${MHMTSCONF}" > "$mts_fakesendmail"
+printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail"
+MHMTSCONF="$mts_fakesendmail"
+
+# arguments: rcvdist switches
+test_rcvdist ()
+{
+ run_prog $rcvdist "$@"
+
+ # fakesendmail drops the message and any cc's into this mbox.
+ mbox="${MH_TEST_DIR}"/Mail/fakesendmail.mbox
+ inc -silent -file "$mbox"
+ rm -f "$mbox"
+
+ # It's hard to calculate the exact Date: header post is going to
+ # use, so we'll just use sed to remove the actual date so we can
+ # easily compare it against our "correct" output.
+ sed -e 's/^Resent-Date:.*/Resent-Date:/' `mhpath last` > "$actual"
+
+ check "$expected" "$actual"
+}
+
+# check with address
+start_test 'with address'