3 # fakesendmail - A fake sendmail program used by the nmh test suite
4 # to test the sendmail/smtp and sendmail/pipe mts
7 # This code is Copyright (c) 2012, by the authors of nmh. See the
8 # COPYRIGHT file in the root or documentation directory of the nmh
9 # distribution for complete copyright information.
12 if [ "$MH_TEST_DIR"x = x ]; then
13 printf '%s is intended for use only by the nmh test suite\n' "$0"
17 #### Puts message on stdin in a drop that the test knows about.
18 deliver="$MH_LIB_DIR/rcvpack $MH_TEST_DIR/Mail/fakesendmail.mbox"
22 [ "$arg" = -t ] && found_dasht=1
25 if [ $found_dasht -eq 0 ]; then
30 printf '%s\n' "220 If it can't be done in Bourne shell it's not worth doing"
32 #### Strip off carriage returns, they confuse the pattern matching.
33 line=`printf %s "$line" | tr -d '\r'`
36 DATA) printf '354 do tell\n'; datamode=1 ;;
37 .) printf '250 done\n'; datamode=0;
38 printf %s "$msg" | $deliver; msg= ;;
39 QUIT) printf '221 byenow\n'; break ;;
40 *) [ $datamode -eq 1 ] && msg="${msg}${line}
41 " || printf '250 OK\n'
47 #### This will delete any lines in the message body that start with Bcc:!
48 sed -e '/^[Bb][Cc][Cc]:/d' | $deliver