2

It is possible to configure Mailman to log the IP address of the sender of each message?

It appears the correct configuration directive (from Defaults.py) is SMTP_LOG_SUCCESS. It logs to /var/log/mailman/post:

SMTP_LOG_SUCCESS = (
    'post',
    'post to %(listname)s from %(sender)s, size=%(size)d, message-id=%(msg_message-id)s,   success')

I copied this directive to mm_cfg.py, tried adding %(ip) and %(remote) (just guesses), and restarted Mailman, but it didn't work.

The dictionary of available variables appears to be in Mailman/Handlers/SMTPDirect.py, lines 173-180. However, I don't know Python well enough to make the message sender's IP address available as a variable here.

d = MsgSafeDict(msg, {'time'    : t1-t0,
                      # BAW: Urg.  This seems inefficient.
                      'size'    : len(msg.as_string()),
                      '#recips' : len(recips),
                      '#refused': len(refused),
                      'listname': mlist.internal_name(),
                      'sender'  : origsender,
                      })  
richardkmiller
  • 255
  • 2
  • 12

1 Answers1

1

hei. What SMTPDirect does is

Local SMTP direct drop-off.
This module delivers messages via SMTP to a locally specified daemon.

There is no info about the senders IP. So this is, at least how i understand your question, not what you want.

I would suggest another way: depending on your setup, "clone" the Mailbox where the original mails go to. Extract the IPs from there, you could use shell tools or python to do that.

The IPs are not directly coupled to the Mails Mailman is processing, but you can look up the IPs.

Otherwise i fear you have to patch mailman, which is a bitchy piece of code (imo)

jojoo
  • 444
  • 3
  • 10
  • thanks for the response. It sounds like it would be a pain to dive into Mailman, so my allusions of a fast solution may be out of the question. (Frankly, cloning a mailbox would require some research too.) – richardkmiller Jun 15 '11 at 15:41