1fatal() { 2 for line in "$@"; do 3 echo "$line" >&2 4 done 5 exit 100; 6} 7 8grephdr() { 9 # Search for the header line, and produce an error if it didn't match. 10 egrep "^$*$" "$QQHDR" >/dev/null 2>&1 || \ 11 { 12 echo "Header is missing or wrong $1 line:"; 13 grep -i "^$1" "$QQHDR" 14 BUG="${BUG} headers" 15 prompt "..............: " 16 } 17 # Remove any found lines from the header file 18 grep -iv "^$1" "$QQHDR" >"${TMP}hdr" 19 mv -f "${TMP}hdr" "$QQHDR" 20} 21 22grepbody() { 23 egrep "^$*$" "$QQBODY" >/dev/null 2>&1 || \ 24 { 25 echo "Body is missing or wrong $1 line:"; 26 grep -i "^$1" "$QQBODY" 27 BUG="${BUG} body" 28 prompt "..............: " 29 } 30} 31 32grepbodynot() { 33 egrep "^$*" "$QQBODY" >/dev/null 2>&1 && \ 34 { 35 echo "Body contains extraneous $1 line:"; 36 grep -i "^$1" "$QQBODY" 37 BUG="${BUG} body" 38 prompt "..............: " 39 } 40} 41 42grephdr_std() { 43 grephdr Message-ID: "<[0123456789]*\\.[0123456789]*\\.ezmlm@${HOST}>" 44 grephdr Delivered-To: "responder for ${LIST}@${HOST}" 45 grephdr MIME-Version: 1.0 46} 47 48grephdr_list() { 49 grephdr Mailing-List: "contact ${LIST}-help@${HOST}; run by ezmlm" 50 grephdr List-Help: "<mailto:${LIST}-help@${HOST}>" 51 grephdr List-Post: "<mailto:${LIST}@${HOST}>" 52 grephdr List-Subscribe: "<mailto:${LIST}-subscribe@${HOST}>" 53 if [ -n "$*" ]; then 54 grephdr List-Unsubscribe: "<mailto:${LIST}-unsubscribe@${HOST}>" 55 fi 56} 57 58grephdr_manage() { 59 grephdr_std 60 grephdr_list 61 grephdr Date: '..* ... .... ..:..:.. [-+]....' 62 grephdr From: "${LIST}-help@${HOST}" 63 grephdr To: "test@example.org" 64 grephdr Content-Type: "text/plain; charset=.*" 65} 66 67grephdr_empty() { 68 # Use this after all other grephdr checks to ensure nothing else was output 69 test -s "$QQHDR" && \ 70 { 71 echo "Headers contained extra lines:" 72 cat "$QQHDR" 73 BUG="${BUG} headers" 74 } 75} 76 77checkenv() 78{ 79 msg="$1" 80 head -n 1 "$QQENV" | grep "^F$2$" >/dev/null \ 81 || fatal "envelope for $msg has wrong sender" 82 test $# = $(wc -l <"$QQENV") \ 83 || fatal "envelope for $msg has wrong number of recipients" 84 shift 2 85 for rcpt in "$@"; do 86 grep "^T$rcpt$" "$QQENV" >/dev/null \ 87 || fatal "envelope for $msg is missing recipient $rcpt" 88 done 89} 90 91############################### 92# message generating function # 93############################### 94make_body() 95{ 96 echo "This is a simple message body" 97 echo "--bound123ary" 98 echo "Content-type: Text/pLAIn" 99 echo 100 echo "plain text" 101 echo "--bound123ary" 102 echo "Content-type: texT/Html" 103 echo 104 echo "html text" 105 echo "--bound123ary--" 106 echo 107 echo "junk after boundary" 108 return 0 109} 110 111qqclean() 112{ 113 rm -f "$QQBODY" "$QQENV" "$QQHDR" "$QQMSG" "$QQMSG".* 114} 115 116make_message() 117{ 118 echo "ReCEIved: #LAST#" 119 echo "ReCeIved: #PENULTIMATE#" 120 echo "retuRN-RECeipt-to: nobody" 121 echo "To: $TO" 122 echo "CC: " 123 echo " $CC" 124 echo "FROM: $FROM" 125 if [ ! -z "$CONTENT" ]; then 126 echo "MIME-Version: 1.0" 127 echo "Content-type: $CONTENT;" 128 echo " boundary=bound123ary${AFTERBOUND}" 129 fi 130 if [ ! -z "$SUBJECT" ]; then 131 echo "Subject: $SUBJECT" 132 fi 133 echo 134 make_body 135 return 0 136} 137 138######################### 139# Tests for file status # 140######################### 141exists() { 142 for file in "$@"; do 143 test -e "$file" || return 1 144 done 145 return 0 146} 147 148msgexists() { 149 test -s "$QQMSG" -a -s "${QQENV}" 150} 151 152####################################### 153# Extract parts of the message header # 154####################################### 155gethdr() { 156 sed -e "/^$1:/!d; s/[^ ]* *//;" "$QQHDR" 157} 158 159########################################## 160# Run ezmlm-manage and check the results # 161########################################## 162check_manage() { 163 local name=$1 164 local options=$2 165 local exit=$3 166 local exitmsg="$4" 167 local text="$5" 168 local sender="$6" 169 ${EZBIN}/ezmlm-manage -a $options "$DIR" < "$TMP" > "$ERR" 2>&1 170 local e=$? 171 test $e -eq $exit || fatal "ezmlm-manage ($name) $exitmsg (exit $e)" 172 if [ -n "$text" ] 173 then 174 grep "ezmlm-manage: info: sending $text$" "$ERR" >/dev/null 2>&1 \ 175 || fatal "ezmlm-manage ($name) sent wrong text (should be $text)" 176 fi 177 if [ -n "$sender" ] 178 then 179 shift 6 180 checkenv $name "$sender" "$@" 181 fi 182} 183