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 the draft message, always the last argument, and whether we've
14 # been called with -whom; the latter sucks.
16 # The case statement has to know about switches that take arguments;
17 # add to this list as necessary.
23 while test $# -gt 0; do
25 -al* | -filt* | -wi* | -client | -idanno | -server | \
26 -partno | -saslmech | -user | -por* | -width | \
27 -file* | -mhl* | -mt* | -cr* | -lib* | -auth* | -sendmail)
42 echo "Cannot find draft message name in argument list"
46 realpost
="$(mhparam libdir)/post"
49 echo "Usage: [post switches] filename"
53 find_draftmessage
"$@"
55 if [ $whom -eq 1 ]; then
59 fromhost
=$(scan -format '%<{resent-from}%(host{resent-from})%|%(host{from
})%>' -file "$draftmessage")
62 echo "Unable to run scan on draft file $draftmessage, aborting"
66 if [ -z "$fromhost" ]; then
67 echo "Could not determine hostname of From: address"
72 # Here we use the hostname in the "from" address, but you could use anything
77 postflags="-server smtp.host1.com -sasl -port submission"
81 postflags="-server smtp.host2.com -sasl -tls -port submission"
85 echo "Don't know how to send email from
$fromhost"
90 exec "$realpost" $postflags "$@
"