5
5
Mailman has an NNTP gateway, whereby messages posted to the mailing list can
6
be forwarded onto an NNTP newsgroup. Typically this means Usenet, but since
7
NNTP is to Usenet as IP is to the web, it's more general than that.
6
be forwarded onto an NNTP newsgroup.
9
>>> mlist = create_list('_xtest@example.com')
8
>>> mlist = create_list('test@example.com')
11
10
Gatewaying from the mailing list to the newsgroup happens through a separate
12
11
``nntp`` queue and happen immediately when the message is posted through to
13
12
the list. Note that gatewaying from the newsgroup to the list happens via a
14
cronjob (currently not shown).
16
15
There are several situations which prevent a message from being gatewayed to
17
16
the newsgroup. The feature could be disabled, as is the default.
27
26
>>> handler = config.handlers['to-usenet']
28
27
>>> handler.process(mlist, msg, {})
30
>>> switchboard = config.switchboards['news']
28
>>> from mailman.testing.helpers import get_queue_messages
29
>>> get_queue_messages('nntp')
34
32
Even if enabled, messages that came from the newsgroup are never gated back to
37
35
>>> mlist.gateway_to_news = True
38
>>> handler.process(mlist, msg, {'fromusenet': True})
36
>>> handler.process(mlist, msg, dict(fromusenet=True))
37
>>> get_queue_messages('nntp')
42
40
Neither are digests ever gated to the newsgroup.
44
>>> handler.process(mlist, msg, {'isdigest': True})
42
>>> handler.process(mlist, msg, dict(isdigest=True))
43
>>> get_queue_messages('nntp')
48
46
However, other posted messages get gated to the newsgroup via the nntp queue.
49
47
The list owner can set the linked newsgroup and the nntp host that its
50
48
messages are gated to.
52
51
>>> mlist.linked_newsgroup = 'comp.lang.thing'
53
52
>>> mlist.nntp_host = 'news.example.com'
54
53
>>> handler.process(mlist, msg, {})
55
>>> len(switchboard.files)
54
>>> messages = get_queue_messages('nntp')
57
>>> filebase = switchboard.files[0]
58
>>> msg, msgdata = switchboard.dequeue(filebase)
59
>>> switchboard.finish(filebase)
60
>>> print msg.as_string()
58
>>> print messages[0].msg.as_string()
61
59
Subject: An important message
63
61
Something of great import.
65
>>> dump_msgdata(msgdata)
64
>>> dump_msgdata(messages[0].msgdata)
67
listname : _xtest@example.com
66
listname : test@example.com