David Collantes <[EMAIL PROTECTED]> writes:
> On 06-13-2003 at 14:06 EDT, Tim Legant <[EMAIL PROTECTED]> wrote:
>
> > import socket
> > ADDED_HEADERS_CLIENT = {
> > "X-Originating-IP" : socket.gethostbyname(socket.gethostname())
> > }
>
> Hmm, that gives the IP of the server (machine) running TMDA, not the IP of the
> user using TMDA to send email throught it... Any tips on that one?
Ah. You didn't say you were using tmda-ofmipd and wanted the remote
IP. Unfortunately, there's no nice way to get that IP without
modifying tmda-ofmipd. It would probably need to be set in the
environment and then the user's config file (or the global config,
/etc/tmdarc) could read it and set your header. Here's an ugly hack
to suck it out of the Received header that tmda-ofmipd puts in the
environment.
In either the global or a user's config:
import os # should already be in the config file...
ADDED_HEADERS_CLIENT = {} # you can put any addl. headers you want here.
rcvd = os.environ.get('TMDA_OFMIPD_RECEIVED')
if rcvd:
import re
mo = re.search(r'(\d+\.\d+\.\d+\.\d+)', rcvd)
ADDED_HEADERS_CLIENT['X-Originating-IP'] = mo.group(1)
The test for whether the 'rcvd' variable is present is necessary
because programs other than tmda-inject (spawned by tmda-ofmipd) read
the config file and they will not find the TMDA_OFMIPD_RECEIVED
environment variable. The X-Originating-IP header will only added if
an IP is actually found.
If you have other headers you want to add to outgoing mail, set them
up in the first ADDED_HEADERS_CLIENT line above the IP-finding code,
following the explanation in Defaults.py or
http://tmda.net/config-vars.html#ADDED_HEADERS_CLIENT.
WARNING: Untested!!
Tim
_____________________________________________
tmda-users mailing list ([EMAIL PROTECTED])
http://tmda.net/lists/listinfo/tmda-users