with test-mts.
test/post/test-post-basic test/post/test-post-multiple \
test/post/test-post-dcc test/post/test-post-fcc \
test/post/test-post-multifrom test/post/test-post-envelope \
- test/post/test-post-group test/post/test-sendmail-pipe \
+ test/post/test-post-group test/post/test-mts \
test/prompter/test-prompter \
test/rcv/test-rcvdist test/rcv/test-rcvpack test/rcv/test-rcvstore \
test/refile/test-refile \
#define MTS_SENDMAIL_SMTP 1
#define MTS_SENDMAIL_PIPE 2
extern int sm_mts;
+void save_mts_method (const char *);
extern char *sendmail;
.BR sendmail .
It will still speak SMTP with this local copy of
.BR sendmail .
+For backward compatibility,
+.B sendmail/smtp
+can be abbreviated to
+.BR sendmail .
.PP
The third alternative,
.BR sendmail/pipe ,
.RB [ \-watch " | " \-nowatch ]
.RB [ \-width
.IR columns ]
+.RB [ \-mts
+.IR smtp " | " sendmail/smtp " | " sendmail/pipe ]
.RB [ \-server
.IR servername ]
.RB [ \-port
will be instructed to not send any bounces in response to the message.
Not all mail transport systems support this feature.
.PP
+The mail transport system default is provided in
+.I %etcdir%/mts.conf
+but can be overriiden here with the
+.B \-mts
+switch.
+.PP
If nmh is using the SMTP MTA, the
.B \-server
and the
.IR seconds ]
.RB [ \-verbose " | " \-noverbose ]
.RB [ \-watch " | " \-nowatch ]
+.RB [ \-mts
+.IR smtp " | " sendmail/smtp " | " sendmail/pipe ]
.RB [ \-server
.IR servername ]
.RB [ \-port
.B send
as to how long it should make header lines containing addresses.
.PP
+The mail transport system default is provided in
+.I %etcdir%/mts.conf
+but can be overriiden here with the
+.B \-mts
+switch.
+.PP
If nmh is using the SMTP MTA, the
.B \-server
and the
.RB [ \-draftmessage
.IR msg ]
.RB [ \-nodraftfolder ]
+.RB [ \-mts
+.IR smtp " | " sendmail/smtp " | " sendmail/pipe ]
.RB [ \-server
.IR servername ]
.RB [ \-port
.BR mh-draft (5)
man page for more information.
.PP
+The mail transport system default is provided in
+.I %etcdir%/mts.conf
+but can be overriiden here with the
+.B \-mts
+switch.
+.PP
If nmh is using the SMTP MTA, the
.B \-server
and the
/*
* MTS specific variables
*/
-static char *sm_method = "smtp";
+static char *mts_method = "smtp";
int sm_mts = MTS_SENDMAIL_SMTP;
char *sendmail = SENDMAILPATH;
{ "uucplfil", &uucplfil },
{ "mmdelim1", &mmdlm1 },
{ "mmdelim2", &mmdlm2 },
- { "mts", &sm_method },
+ { "mts", &mts_method },
{ "sendmail", &sendmail },
{ "clientname", &clientname },
{ "servers", &servers },
};
+/* Convert name of mts method to integer value and store it. */
+void
+save_mts_method (const char *value) {
+ if (! mh_strcasecmp (value, "smtp")) {
+ mts_method = "smtp";
+ sm_mts = MTS_SMTP;
+ } else if (! mh_strcasecmp (value, "sendmail/smtp") ||
+ ! mh_strcasecmp (value, "sendmail")) {
+ mts_method = "sendmail/smtp";
+ sm_mts = MTS_SENDMAIL_SMTP;
+ } else if (! mh_strcasecmp (value, "sendmail/pipe")) {
+ mts_method = "sendmail/pipe";
+ sm_mts = MTS_SENDMAIL_PIPE;
+ } else {
+ adios (NULL, "unsupported mts selection \"%s\"", value);
+ }
+}
+
+
/*
* Read the configuration file for the nmh interface
* to the mail transport system (MTS).
Everyone = atoi (everyone);
- if (strcmp(sm_method, "smtp") == 0)
- sm_mts = MTS_SMTP;
- else if (strcmp(sm_method, "sendmail/smtp") == 0)
- sm_mts = MTS_SENDMAIL_SMTP;
- else if (strcmp(sm_method, "sendmail/pipe") == 0)
- sm_mts = MTS_SENDMAIL_PIPE;
- else {
- advise(NULL, "unsupported \"mts\" value in mts.conf: %s", sm_method);
- sm_mts = MTS_SENDMAIL_SMTP;
- }
+ save_mts_method (mts_method);
}
#! /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
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 "220 If it can't be done in Bourne shell it's not worth doing\n"
+ while read line; do
+ #### Strip off carriage returns, they confuse the pattern matching.
+ line=`printf "$line" | tr -d '\r'`
+
+ case "$line" in
+ DATA) printf "354 do tell\n"; datamode=1 ;;
+ .) printf "250 done\n"; datamode=0; printf "$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
--- /dev/null
+#!/bin/sh
+#
+# Test the sendmail/smtp and sendmail/pipe transport methods
+# via the -mts option.
+#
+
+set -e
+
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname "$0"`/../..
+ MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
+fi
+
+. "${srcdir}/test/post/test-post-common.sh"
+
+
+cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
+From: Mr Nobody <nobody@example.com>
+To: Somebody Else <somebody@example.com>
+Subject: Test
+
+This is a test
+EOF
+
+cat > "${testname}.expected" <<EOF
+EHLO nosuchhost.example.com
+MAIL FROM:<nobody@example.com>
+RCPT TO:<somebody@example.com>
+DATA
+From: Mr Nobody <nobody@example.com>
+To: Somebody Else <somebody@example.com>
+Subject: Test
+Date:
+
+This is a test
+.
+QUIT
+EOF
+
+# check invalid -mts selection
+run_test "send -draft -mts invalid" \
+"post: unsupported mts selection \"invalid\"
+send: message not delivered to anyone"
+
+test_post "${testname}.actual" "${testname}.expected" "-mts smtp"
+
+#### Rely on sendmail/smtp or sendmail/pipe below to override default mts.
+mts_fakesendmail="${MHMTSCONF}-fakesendmail"
+cp "${MHMTSCONF}" "$mts_fakesendmail"
+printf "%s\n" "sendmail: ${srcdir}/test/fakesendmail" >>"$mts_fakesendmail"
+MHMTSCONF="$mts_fakesendmail"
+
+# $1: option switches for send
+# remaining arguments: expected output(s)
+test_sendmail ()
+{
+ send -draft -mts "$1"
+ shift
+
+ # 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" "$mbox.map"
+
+ n=1
+ for expected in "$@"; do
+ #
+ # 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/^Date:.*/Date:/' "`mhpath cur`" > "${testname}.actual$n"
+
+ check "${testname}.actual$n" "$expected"
+
+ if [ "`mhpath cur`" != "`mhpath last`" ]; then
+ folder next >/dev/null
+ arith_eval $n + 1; n=$arith_val
+ fi
+ done
+}
+
+# check -mts sendmail/smtp
+cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
+From: Mr Nobody <nobody@example.com>
+To: Somebody Else <somebody@example.com>
+Subject: Test
+
+This is a test
+.
+EOF
+
+cat > "${testname}.expected" <<EOF
+From: Mr Nobody <nobody@example.com>
+To: Somebody Else <somebody@example.com>
+Subject: Test
+Date:
+
+This is a test
+..
+EOF
+
+test_sendmail sendmail/smtp "${testname}.expected"
+
+# check -mts sendmail/pipe
+# Dots are not stuffed because sendmail/pipe causes sendmail to be
+# invoked with -i.
+cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
+From: Mr Nobody <nobody@example.com>
+To: Somebody Else <somebody@example.com>
+Subject: Test
+
+This is a test
+.
+EOF
+
+cat > "${testname}.expected" <<EOF
+From: Mr Nobody <nobody@example.com>
+To: Somebody Else <somebody@example.com>
+Subject: Test
+Date:
+
+This is a test
+.
+EOF
+
+test_sendmail sendmail/pipe "${testname}.expected"
+
+# check Bcc
+cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
+From: Mr Nobody <nobody@example.com>
+To: Somebody Else <somebody@example.com>
+Bcc: Silent Partner <bcc@example.com>
+Subject: Test
+
+This is a test
+.
+EOF
+
+cat > "${testname}.expected1" <<EOF
+From: Mr Nobody <nobody@example.com>
+To: Somebody Else <somebody@example.com>
+Subject: Test
+Date:
+
+This is a test
+.
+EOF
+
+cat > "${testname}.expected2" <<EOF
+Date:
+Subject: Test
+
+------- Blind-Carbon-Copy
+
+From: Mr Nobody <nobody@example.com>
+To: Somebody Else <somebody@example.com>
+Subject: Test
+Date:
+
+This is a test
+.
+
+------- End of Blind-Carbon-Copy
+EOF
+
+test_sendmail sendmail/pipe "${testname}.expected1" "${testname}.expected2"
+
+
+rm -f ${MHMTSCONF}
+
+exit ${failed:-0}
#
# One "post" test run. Ok, yeah, we're using "send", but that's just
# because it's easier.
-#
+# $1: output filename for fakesmtp, i.e., the sent message
+# $2: expected output
+# $3: optional switches for send
test_post ()
{ "${MH_OBJ_DIR}/test/fakesmtp" "$1" $localport &
# retry a few times if it fails...
status=1
for i in 0 1 2 3 4 5 6 7 8 9; do
- if send -draft -server 127.0.0.1 -port $localport >/dev/null 2>&1; then
+ if send -draft -server 127.0.0.1 -port $localport $3 >/dev/null 2>&1
+ then
status=0
break
fi
+++ /dev/null
-#!/bin/sh
-#
-# Test the basic behavior of post when configured with sendmail/pipe
-# delivery method.
-#
-
-set -e
-
-if test -z "${MH_OBJ_DIR}"; then
- srcdir=`dirname "$0"`/../..
- MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
-fi
-
-. "${MH_OBJ_DIR}/test/common.sh"
-
-setup_test
-testname="${MH_TEST_DIR}/$$"
-
-#### Force test of sendmail/pipe regardless of configuration.
-mts_pipe="${MHMTSCONF}-pipe"
-sed -e 's/mts: *.*/mts: sendmail\/pipe/' "${MHMTSCONF}" >"$mts_pipe"
-printf "%s\n" "sendmail: ${srcdir}/test/fakesendmail" >>"$mts_pipe"
-MHMTSCONF="$mts_pipe"
-
-test_sendmail_pipe ()
-{
- send -draft
-
- # 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" "$mbox.map"
-
- n=1
- for expected in "$@"; do
- #
- # 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/^Date:.*/Date:/' "`mhpath cur`" > "${testname}.actual$n"
-
- check "${testname}.actual$n" "$expected"
-
- if [ "`mhpath cur`" != "`mhpath last`" ]; then
- folder next >/dev/null
- arith_eval $n + 1; n=$arith_val
- fi
- done
-}
-
-#
-# Basic test - Simple message, single user, single recipient. Dots
-# are not stuffed because sendmail/pipe causes sendmail to be invoked
-# with -i.
-#
-cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
-From: Mr Nobody <nobody@example.com>
-To: Somebody Else <somebody@example.com>
-Subject: Test
-
-This is a test
-.
-EOF
-
-cat > "${testname}.expected" <<EOF
-From: Mr Nobody <nobody@example.com>
-To: Somebody Else <somebody@example.com>
-Subject: Test
-Date:
-
-This is a test
-.
-EOF
-
-test_sendmail_pipe "${testname}.expected"
-
-
-# check Bcc
-cat > "${MH_TEST_DIR}/Mail/draft" <<EOF
-From: Mr Nobody <nobody@example.com>
-To: Somebody Else <somebody@example.com>
-Bcc: Silent Partner <bcc@example.com>
-Subject: Test
-
-This is a test
-.
-EOF
-
-cat > "${testname}.expected1" <<EOF
-From: Mr Nobody <nobody@example.com>
-To: Somebody Else <somebody@example.com>
-Subject: Test
-Date:
-
-This is a test
-.
-EOF
-
-cat > "${testname}.expected2" <<EOF
-Date:
-Subject: Test
-
-------- Blind-Carbon-Copy
-
-From: Mr Nobody <nobody@example.com>
-To: Somebody Else <somebody@example.com>
-Subject: Test
-Date:
-
-This is a test
-.
-
-------- End of Blind-Carbon-Copy
-EOF
-
-test_sendmail_pipe "${testname}.expected1" "${testname}.expected2"
-
-
-rm -f ${MHMTSCONF}
-
-exit ${failed:-0}
{ "fileproc", -4 },
#define MHLPROCSW 39
{ "mhlproc", -3 },
+#define MTSSW 40
+ { "mts smtp|sendmail/smtp|sendmail/pipe", 2 },
{ NULL, 0 }
};
adios (NULL, "missing argument to %s", argp[-2]);
mhlproc = cp;
continue;
+
+ case MTSSW:
+ if (!(cp = *argp++) || *cp == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+ save_mts_method (cp);
+ continue;
}
}
if (msg)
{ "tls", TLSminc(-3) },
#define NTLSSW 47
{ "notls", TLSminc(-5) },
+#define MTSSW 48
+ { "mts smtp|sendmail/smtp|sendmail/pipe", 2 },
{ NULL, 0 }
};
case SASLMXSSFSW:
case USERSW:
case PORTSW:
+ case MTSSW:
vec[vecp++] = --cp;
if (!(cp = *argp++) || *cp == '-')
adios (NULL, "missing argument to %s", argp[-2]);
{ "tls", TLSminc(-3) },
#define NTLSSW 46
{ "notls", TLSminc(-5) },
+#define MTSSW 47
+ { "mts smtp|sendmail/smtp|sendmail/pipe", 2 },
{ NULL, 0 }
};
case SASLMECHSW:
case USERSW:
case PORTSW:
+ case MTSSW:
vec[vecp++] = --cp;
if (!(cp = *argp++) || *cp == '-') {
advise (NULL, "missing argument to %s", argp[-2]);
{ "tls", TLSminc(-3) },
#define NTLSSW 17
{ "notls", TLSminc(-5) },
+#define MTSSW 18
+ { "mts smtp|sendmail/smtp|sendmail/pipe", 0 },
{ NULL, 0 }
};
case USERSW:
case PORTSW:
case SASLMECHSW:
+ case MTSSW:
vec[vecp++] = --cp;
if (!(cp = *argp++) || *cp == '-')
adios (NULL, "missing argument to %s", argp[-2]);