diff options
| author | Barry Warsaw | 2008-04-26 01:57:53 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2008-04-26 01:57:53 -0400 |
| commit | 67e437883d520bf7ea78ae55235892aa946ef0b4 (patch) | |
| tree | 03b658e421da0e67bacc12c7203851f5baae5daf | |
| parent | fbd382c07dc621bda9b724675b1df75746d07179 (diff) | |
| download | mailman-67e437883d520bf7ea78ae55235892aa946ef0b4.tar.gz mailman-67e437883d520bf7ea78ae55235892aa946ef0b4.tar.zst mailman-67e437883d520bf7ea78ae55235892aa946ef0b4.zip | |
Handle commands in the body of a plain text email message.
| -rw-r--r-- | mailman/queue/command.py | 5 | ||||
| -rw-r--r-- | mailman/queue/docs/command.txt | 45 |
2 files changed, 49 insertions, 1 deletions
diff --git a/mailman/queue/command.py b/mailman/queue/command.py index 319cab87c..e9009809e 100644 --- a/mailman/queue/command.py +++ b/mailman/queue/command.py @@ -111,7 +111,10 @@ class CommandFinder: line = self.command_lines.pop(0) self.processed_lines.append(line) parts = line.strip().split() - yield parts[0], tuple(parts[1:]) + if len(parts) == 0: + continue + command = parts.pop(0) + yield command, tuple(parts) diff --git a/mailman/queue/docs/command.txt b/mailman/queue/docs/command.txt index 5168dda07..fdad3bb5c 100644 --- a/mailman/queue/docs/command.txt +++ b/mailman/queue/docs/command.txt @@ -9,6 +9,10 @@ message is sent to the list's -request address. >>> from mailman.app.lifecycle import create_list >>> mlist = create_list(u'test@example.com') + +A command in the Subject +------------------------ + For example, the 'echo' command simply echoes the original command back to the sender. The command can be in the Subject header. @@ -59,3 +63,44 @@ And now the response is in the virgin queue. [..., ('listname', u'test@example.com'), ..., ('recips', [u'aperson@example.com']), ...] + + +A command in the body +--------------------- + +The command can also be found in the body of the message, as long as the +message is plain text. + + >>> msg = message_from_string("""\ + ... From: bperson@example.com + ... To: test-request@example.com + ... Message-ID: <bobcat> + ... + ... echo foo bar + ... """) + + >>> inject_message(mlist, msg, qdir=config.CMDQUEUE_DIR) + >>> command.run() + >>> len(virgin_queue.files) + 1 + >>> item = get_queue_messages(virgin_queue)[0] + >>> print item.msg.as_string() + Subject: The results of your email commands + From: test-bounces@example.com + To: bperson@example.com + ... + Precedence: bulk + <BLANKLINE> + The results of your email command are provided below. + <BLANKLINE> + - Original message details: + From: bperson@example.com + Subject: n/a + Date: ... + Message-ID: <bobcat> + <BLANKLINE> + - Results: + echo foo bar + <BLANKLINE> + - Done. + <BLANKLINE> |
