3 # localpostproc - A sample postproc which changes the submission email server
4 # based on user-supplied criteria.
6 # The basic concept is that we change where we submit mail to based on the
7 # message contents. We use scan(1) to get out fields we care about. But
8 # really, you could use ANY criteria, such as environment variables,
13 # Find out which message is the draft message; yes, this sucks.
15 # The case statement has to know about switches that take arguments;
16 # add to this list as necessary.
22 while test $# -gt 0; do
24 -al* | -filt* | -wi* | -client | -idanno | -server | \
25 -partno | -saslmech | -user | -por* | -width | \
26 -file* | -mhl* | -mt* | -cr* | -lib* | -auth* | -sendmail)
41 echo "Cannot find draft message name in argument list"
45 realpost
="$(mhparam libdir)/post"
48 echo "Usage: [post switches] filename"
52 find_draftmessage
"$@"
54 if [ $whom -eq 1 ]; then
58 fromhost
=$(scan -format '%<{resent-from}%(host{resent-from})%|%(host{from
})%>' -file "$draftmessage")
61 echo "Unable to run scan on draft file $draftmessage, aborting"
65 if [ -z "$fromhost" ]; then
66 echo "Could not determine hostname of From: address"
71 # Here we use the hostname in the "from" address, but you could use anything
76 postflags="-server smtp.host1.com -sasl -port submission"
80 postflags="-server smtp.host2.com -sasl -tls -port submission"
84 echo "Don't know how to send email from
$fromhost"
89 exec "$realpost" $postflags "$@
"