summaryrefslogtreecommitdiff
path: root/src/mailman/queue/docs/lmtp.txt
blob: 5961bea50f7f5178456ba5718302c4d25e22f4e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
===========
LTMP server
===========

Mailman can accept messages via LMTP (RFC 2033).  Most modern mail servers
support LMTP local delivery, so this is a very portable way to connect Mailman
with your mail server.

Our LMTP server is fairly simple though; all it does is make sure that the
message is destined for a valid endpoint, e.g. mylist-join@example.com.

Let's start a testable LMTP queue runner.

    >>> from mailman.testing import helpers
    >>> master = helpers.TestableMaster()
    >>> master.start('lmtp')

It also helps to have a nice LMTP client.

    >>> lmtp = helpers.get_lmtp_client()
    (220, '... Python LMTP queue runner 1.0')
    >>> lmtp.lhlo('remote.example.org')
    (250, ...)


Posting address
===============

If the mail server tries to send a message to a nonexistent mailing list, it
will get a 550 error.

    >>> lmtp.sendmail(
    ...     'anne.person@example.com',
    ...     ['mylist@example.com'], """\
    ... From: anne.person@example.com
    ... To: mylist@example.com
    ... Subject: An interesting message
    ... Message-ID: <aardvark>
    ...
    ... This is an interesting message.
    ... """)
    Traceback (most recent call last):
    ...
    SMTPDataError: (550, 'Requested action not taken: mailbox unavailable')

Once the mailing list is created, the posting address is valid.

    >>> create_list('mylist@example.com')
    <mailing list "mylist@example.com" at ...>

    >>> transaction.commit()
    >>> lmtp.sendmail(
    ...     'anne.person@example.com',
    ...     ['mylist@example.com'], """\
    ... From: anne.person@example.com
    ... To: mylist@example.com
    ... Subject: An interesting message
    ... Message-ID: <badger>
    ...
    ... This is an interesting message.
    ... """)
    {}


Sub-addresses
=============

The LMTP server understands each of the list's sub-addreses, such as -join,
-leave, -request and so on.  If the message is posted to an invalid
sub-address though, it is rejected.

    >>> lmtp.sendmail(
    ...     'anne.person@example.com',
    ...     ['mylist-bogus@example.com'], """\
    ... From: anne.person@example.com
    ... To: mylist-bogus@example.com
    ... Subject: Help
    ... Message-ID: <cow>
    ...
    ... Please help me.
    ... """)
    Traceback (most recent call last):
    ...
    SMTPDataError: (550, 'Requested action not taken: mailbox unavailable')

But the message is accepted if posted to a valid sub-address.

    >>> lmtp.sendmail(
    ...     'anne.person@example.com',
    ...     ['mylist-request@example.com'], """\
    ... From: anne.person@example.com
    ... To: mylist-request@example.com
    ... Subject: Help
    ... Message-ID: <dog>
    ...
    ... Please help me.
    ... """)
    {}


Clean up
========

    >>> master.stop()