summaryrefslogtreecommitdiff
path: root/src/mailman/handlers/docs/acknowledge.rst
blob: 42cab04a03e0a2aea1399c8c0671217578e2d030 (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
======================
Message acknowledgment
======================

When a user posts a message to a mailing list, and that user has chosen to
receive acknowledgments of their postings, Mailman will sent them such an
acknowledgment.
::

    >>> mlist = create_list('test@example.com')
    >>> mlist.display_name = 'Test'
    >>> mlist.preferred_language = 'en'
    >>> mlist.send_welcome_message = False
    >>> # XXX This will almost certainly change once we've worked out the web
    >>> # space layout for mailing lists now.

    >>> # Ensure that the virgin queue is empty, since we'll be checking this
    >>> # for new auto-response messages.
    >>> from mailman.testing.helpers import get_queue_messages
    >>> get_queue_messages('virgin')
    []

Subscribe a user to the mailing list.
::

    >>> from mailman.interfaces.usermanager import IUserManager
    >>> from zope.component import getUtility
    >>> user_manager = getUtility(IUserManager)

    >>> from mailman.interfaces.member import MemberRole
    >>> user_1 = user_manager.create_user('aperson@example.com')
    >>> address_1 = list(user_1.addresses)[0]
    >>> mlist.subscribe(address_1, MemberRole.member)
    <Member: aperson@example.com on test@example.com as MemberRole.member>


Non-member posts
================

Non-members can't get acknowledgments of their posts to the mailing list.
::

    >>> msg = message_from_string("""\
    ... From: bperson@example.com
    ...
    ... """)

    >>> handler = config.handlers['acknowledge']
    >>> handler.process(mlist, msg, {})
    >>> get_queue_messages('virgin')
    []

We can also specify the original sender in the message's metadata.  If that
person is also not a member, no acknowledgment will be sent either.

    >>> msg = message_from_string("""\
    ... From: bperson@example.com
    ...
    ... """)
    >>> handler.process(mlist, msg,
    ...     dict(original_sender='cperson@example.com'))
    >>> get_queue_messages('virgin')
    []


No acknowledgment requested
===========================

Unless the user has requested acknowledgments, they will not get one.

    >>> msg = message_from_string("""\
    ... From: aperson@example.com
    ...
    ... """)
    >>> handler.process(mlist, msg, {})
    >>> get_queue_messages('virgin')
    []

Similarly if the original sender is specified in the message metadata, and
that sender is a member but not one who has requested acknowledgments, none
will be sent.
::

    >>> user_2 = user_manager.create_user('dperson@example.com')
    >>> address_2 = list(user_2.addresses)[0]
    >>> mlist.subscribe(address_2, MemberRole.member)
    <Member: dperson@example.com on test@example.com as MemberRole.member>

    >>> handler.process(mlist, msg,
    ...     dict(original_sender='dperson@example.com'))
    >>> get_queue_messages('virgin')
    []


Requested acknowledgments
=========================

If the member requests acknowledgments, Mailman will send them one when they
post to the mailing list.

    >>> user_1.preferences.acknowledge_posts = True

The receipt will include the original message's subject in the response body,

    >>> msg = message_from_string("""\
    ... From: aperson@example.com
    ... Subject: Something witty and insightful
    ...
    ... """)
    >>> handler.process(mlist, msg, {})
    >>> messages = get_queue_messages('virgin')
    >>> len(messages)
    1
    >>> dump_msgdata(messages[0].msgdata)
    _parsemsg           : False
    listid              : test.example.com
    nodecorate          : True
    recipients          : {'aperson@example.com'}
    reduced_list_headers: True
    ...
    >>> print(messages[0].msg.as_string())
    ...
    MIME-Version: 1.0
    ...
    Subject: Test post acknowledgment
    From: test-bounces@example.com
    To: aperson@example.com
    ...
    Precedence: bulk
    <BLANKLINE>
    Your message entitled
    <BLANKLINE>
        Something witty and insightful
    <BLANKLINE>
    was successfully received by the Test mailing list.
    <BLANKLINE>
    List info page: http://lists.example.com/listinfo/test@example.com
    Your preferences: http://example.com/aperson@example.com
    <BLANKLINE>

If there is no subject, then the receipt will use a generic message.

    >>> msg = message_from_string("""\
    ... From: aperson@example.com
    ...
    ... """)
    >>> handler.process(mlist, msg, {})
    >>> messages = get_queue_messages('virgin')
    >>> len(messages)
    1
    >>> dump_msgdata(messages[0].msgdata)
    _parsemsg           : False
    listid              : test.example.com
    nodecorate          : True
    recipients          : {'aperson@example.com'}
    reduced_list_headers: True
    ...
    >>> print(messages[0].msg.as_string())
    MIME-Version: 1.0
    ...
    Subject: Test post acknowledgment
    From: test-bounces@example.com
    To: aperson@example.com
    ...
    Precedence: bulk
    <BLANKLINE>
    Your message entitled
    <BLANKLINE>
        (no subject)
    <BLANKLINE>
    was successfully received by the Test mailing list.
    <BLANKLINE>
    List info page: http://lists.example.com/listinfo/test@example.com
    Your preferences: http://example.com/aperson@example.com
    <BLANKLINE>