diff options
| -rw-r--r-- | Mailman/Deliverer.py | 36 | ||||
| -rw-r--r-- | Mailman/Message.py | 25 | ||||
| -rwxr-xr-x | scripts/mailowner | 3 | ||||
| -rwxr-xr-x | scripts/owner | 3 |
4 files changed, 65 insertions, 2 deletions
diff --git a/Mailman/Deliverer.py b/Mailman/Deliverer.py index a34a0810b..fc55c1aca 100644 --- a/Mailman/Deliverer.py +++ b/Mailman/Deliverer.py @@ -45,6 +45,42 @@ class Deliverer: def QuotePeriods(self, text): return string.join(string.split(text, '\n.\n'), '\n .\n') + + # + # this function is used to deliver messages + # that are sent to <listname>-admin. the sender + # is the envelope sender of the message, or if + # that is not available, the sender via Message.GetSender() + # the recipients arg is a list of the current list + # owners. We don't mess with adding list specific + # headers on body modifications so that the address + # will work just like a normal forwarding address + # + def DeliverToOwner(self, msg, recipients): + if not (len(recipients)): + return + sender = msg.GetEnvelopeSender() + if not sender: + sender = msg.GetSender() + cmd = "%s %s" % (mm_cfg.PYTHON, + os.path.join(mm_cfg.SCRIPTS_DIR, "deliver")) + cmdproc = os.popen(cmd, 'w') + + cmdproc.write("%d\n" % self.num_spawns) + cmdproc.write("%s\n" % sender) + for r in recipients: + # Mustn't send blank lines before end of recipients: + if not r: continue + cmdproc.write(r + "\n") + cmdproc.write('\n') + cmdproc.write(string.join(msg.headers, '') + "\n") + cmdproc.write(self.QuotePeriods(msg.body)) + status = cmdproc.close() + if status: + sys.stderr.write('Non-zero exit status: %d' + '\nCommand: %s' % ((status >> 8), cmd)) + + def DeliverToList(self, msg, recipients, header="", footer="", remove_to=0, tmpfile_prefix = ""): if not(len(recipients)): diff --git a/Mailman/Message.py b/Mailman/Message.py index 45c355c9d..83d3d3b6f 100644 --- a/Mailman/Message.py +++ b/Mailman/Message.py @@ -112,6 +112,31 @@ class IncomingMessage(rfc822.Message): return string.lower(mail_address) + def GetEnvelopeSender(self): + # + # look for unix from line and attain address + # from it, return None if there is no unix from line + # this function is used to get the envelope sender + # when mail is sent to a <listname>-admin address + # + if not self.unixfrom: + return None + parts = string.split(self.unixfrom) # XXX assumes no whitespace in address + for part in parts: + # + # perform minimal check for the address + # + if string.find(part, '@') > -1: + user, host = string.split(part, '@', 1) + if not user: + continue + if string.count(host, ".") < 1: # doesn't look qualified + continue + return part + return None + + + def GetSenderName(self): real_name, mail_addr = self.getaddr('from') if not real_name: diff --git a/scripts/mailowner b/scripts/mailowner index d77084b63..3a703a184 100755 --- a/scripts/mailowner +++ b/scripts/mailowner @@ -44,7 +44,8 @@ current_list = MailList.MailList(sys.argv[1]) try: msg = Message.IncomingMessage() if not current_list.bounce_processing or not current_list.ScanMessage(msg): - current_list.DeliverToList(msg, current_list.owner, '', '') + current_list.DeliverToOwner(msg, current_list.owner) + # Let another process run. finally: current_list.Unlock() diff --git a/scripts/owner b/scripts/owner index d77084b63..3a703a184 100755 --- a/scripts/owner +++ b/scripts/owner @@ -44,7 +44,8 @@ current_list = MailList.MailList(sys.argv[1]) try: msg = Message.IncomingMessage() if not current_list.bounce_processing or not current_list.ScanMessage(msg): - current_list.DeliverToList(msg, current_list.owner, '', '') + current_list.DeliverToOwner(msg, current_list.owner) + # Let another process run. finally: current_list.Unlock() |
