Make sendmail read the SMART_HOST from a file

  • Follow


NB: This is a 'I need something which works and it needs to be a text
file with a simple format' solution. I don't claim that it is
particularly elegant or that better solutions to the same problem are
not available.

In order to facilitate setting the value mentioned in the Subject:
from a web less-than-masterfully programmed web interface, I needed to
change a 'stock' Debian sendmail configuration such that it reads that
from a file. This can be done by creating a text file with the
following (example) content (assumed to be /etc/mail/smart-host):

0	relay.example.com

Then, a suitable text map needs to be defined in sendmail.cf (going
via any route you're comfortable with)

Ksmart_host text -v1 -k0 /etc/mail/smart-host

Then, a ruleset needs to be defined in order to use this map. This
ruleset is supposed to be called from the Parse1 ruleset instead of
just expanding $S:

Ssmart_host
R$+			$: $(smart_host 0$) $1

Lastly, the two lines using $S need to be changed as follows:

R$* < @ [ $+ ] > $*	$: $1 < @ [ $2 ] : $>smart_host > $3	Add smart host to path

and

R$* < @ $* > $*		$: $>MailerToTriple < $>smart_host > $1 < @ $2 > $3	glue on smarthost name

This will reread and reparse the smart host file every time the
corresponding ruleset is invoked. It is actually possible to just set
the S macro to the corresponding value and use that (I've just retyped
this out of my head) by first defining a 'macro' map:

Kset macro

and then using a smart_host ruleset which looks like this (based on
the assumption that no two consecutive dots will be in the argument):

Ssmart_host
R$+		$: $1 . . $&S			append value of S
R$+ . . $+	$@ $2 $1			has a value? => done
R$+ . .		$1 . . $(smart_host 0$)		append result of lookup
R$+ . . $+	$(set S $@ $2 $) $2 $1		set S to that, return

(intended to be used in the same place).

I you feel inclined to post a 'my MTA is longer than your MTA' reply,
please skip that.
0
Reply rweikusat (2683) 8/2/2011 12:47:10 PM


0 Replies
147 Views

(page loaded in 0.03 seconds)

Similiar Articles:













7/14/2012 6:40:55 PM


Reply: