X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=test%2Ffakesendmail;h=97f63b15d25a1e1fd6af84a6e0bdcb626cd4eddf;hb=2667af48dccbcb9e25709dea50451dd58d40aeae;hp=fb959e202a6c0164de9fc6c335b9329d2b8a4c51;hpb=84b65bad347129f751e3ed208516697bc3fe1820;p=mmh diff --git a/test/fakesendmail b/test/fakesendmail index fb959e2..97f63b1 100755 --- a/test/fakesendmail +++ b/test/fakesendmail @@ -1,30 +1,49 @@ #! /bin/sh ## # fakesendmail - A fake sendmail program used by the nmh test suite -# to test the sendmail/pipe mts. +# to test the sendmail/smtp and sendmail/pipe mts +# methods. # # This code is Copyright (c) 2012, by the authors of nmh. See the -# COPYRIGHT file in the root directory of the nmh distribution for -# complete copyright information. +# COPYRIGHT file in the root or documentation directory of the nmh +# distribution for complete copyright information. ## if [ "$MH_TEST_DIR"x = x ]; then - printf "$0 is intended for use only by the nmh test suite\n" + printf '%s is intended for use only by the nmh test suite\n' "$0" exit 1 fi +#### Puts message on stdin in a drop that the test knows about. +deliver="$MH_LIB_DIR/rcvpack $MH_TEST_DIR/Mail/fakesendmail.mbox" + found_dasht=0 for arg in "$@"; do [ "$arg" = -t ] && found_dasht=1 done if [ $found_dasht -eq 0 ]; then - printf "$0 is intended to fake \"sendmail -t\" only, but no -t provided\n" - exit 1 -fi + # sendmail/smtp + msg= + datamode=0 -#### Put the message (on stdin) in a drop that the test knows about. -#### This will delete any lines in the message body that start with Bcc:, -#### so avoid those. -sed -e '/^[Bb][Cc][Cc]:/d' | \ -"${MH_LIB_DIR}"/rcvpack "${MH_TEST_DIR}"/Mail/fakesendmail.mbox + printf '%s\n' "220 If it can't be done in Bourne shell it's not worth doing" + while read line; do + #### Strip off carriage returns, they confuse the pattern matching. + line=`printf %s "$line" | tr -d '\r'` + + case "$line" in + DATA) printf '354 do tell\n'; datamode=1 ;; + .) printf '250 done\n'; datamode=0; + printf %s "$msg" | $deliver; msg= ;; + QUIT) printf '221 byenow\n'; break ;; + *) [ $datamode -eq 1 ] && msg="${msg}${line} +" || printf '250 OK\n' + esac + done +else + # sendmail/pipe + + #### This will delete any lines in the message body that start with Bcc:! + sed -e '/^[Bb][Cc][Cc]:/d' | $deliver +fi