Skip to content

Commit 62cb018

Browse files
committed
update
1 parent 0dcefa6 commit 62cb018

1 file changed

Lines changed: 36 additions & 40 deletions

File tree

Mailman/Message.py

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -258,63 +258,59 @@ def as_string(self, unixfrom=False, mangle_from_=True):
258258

259259

260260
class UserNotification(Message):
261-
"""Class for crafting user notifications."""
262-
def __init__(self, recip, sender, subject, text=None, lang=None, charset=None,
263-
_fasttrack=False, _text_is_unicode=False):
261+
"""A message sent to a user."""
262+
def __init__(self, recip, sender, subject=None, text=None, lang=None):
264263
Message.__init__(self)
265-
self['From'] = sender
266264
self['To'] = recip
267-
self['Subject'] = subject
268-
self['Date'] = email.utils.formatdate(localtime=1)
269-
self['X-Mailer'] = 'Mailman/%s' % mm_cfg.VERSION
270-
if lang:
271-
self['X-Accept-Language'] = lang
272-
self['Precedence'] = 'bulk'
265+
self['From'] = sender
266+
if subject:
267+
self['Subject'] = subject
273268
if text:
274-
# In Python 3, text is already a string
275-
# Use the specified charset or default to UTF-8
276-
self.set_payload(text, charset or 'utf-8')
277-
if _fasttrack:
278-
self['X-Ack'] = 'yes'
279-
if lang:
280-
self['X-Accept-Language'] = lang
269+
self.set_payload(text)
270+
self['Auto-Submitted'] = 'auto-generated'
271+
self['Precedence'] = 'bulk'
272+
self['X-Auto-Response-Suppress'] = 'OOF, AutoReply'
273+
self['X-Mailman-Version'] = mm_cfg.VERSION
274+
self['X-No-Archive'] = 'yes'
275+
self.lang = lang
281276

282277
def send(self, mlist, noprecedence=False, **_kws):
283-
"""Send the message to the recipient.
284-
285-
The message is sent via the virgin queue.
286-
"""
287-
# Since we're crafting the message from whole cloth, let's make sure
288-
# this message has a Message-ID. Yes, the MTA would give us one, but
289-
# this is useful for logging to logs/smtp.
290-
if 'message-id' not in self:
291-
self['Message-ID'] = unique_message_id(mlist)
278+
"""Send the message to the recipient."""
292279
if not noprecedence:
293280
self['Precedence'] = 'bulk'
294-
return self._enqueue(mlist, **_kws)
281+
self._enqueue(mlist, **_kws)
295282

296283
def _enqueue(self, mlist, **_kws):
297-
"""Enqueue the message to the virgin queue."""
298284
# Not imported at module scope to avoid import loop
299285
from Mailman.Queue.sbcache import get_switchboard
300-
virginq = get_switchboard(mm_cfg.VIRGINQUEUE_DIR)
301-
virginq.enqueue(self, listname=mlist.internal_name(), **_kws)
286+
outq = get_switchboard(mm_cfg.OUTQUEUE_DIR)
287+
outq.enqueue(self, {'recipient': self['To'],
288+
'sender': self['From'],
289+
'lang': self.lang,
290+
'mlist': mlist,
291+
'version': mm_cfg.QUEUE_VERSION,
292+
}, **_kws)
302293

303294

304295
class OwnerNotification(UserNotification):
305-
"""Class for crafting owner notifications."""
296+
"""A message sent to the list owner."""
306297
def __init__(self, mlist, subject=None, text=None, tomoderators=1):
307-
UserNotification.__init__(self, mlist.GetOwnerEmail(),
308-
get_site_email(mlist.host_name),
309-
subject, text)
310298
if tomoderators:
311-
self['To'] = mlist.GetModeratorEmail()
312-
self['X-Ack-No'] = 'no'
313-
self['Precedence'] = 'bulk'
299+
recip = mlist.GetOwnerEmail()
300+
else:
301+
recip = mlist.GetRequestEmail()
302+
UserNotification.__init__(self, recip, mlist.GetBouncesEmail(),
303+
subject, text, mlist.preferred_language)
304+
self['Reply-To'] = mlist.GetRequestEmail()
305+
self['X-List-Administrivia'] = 'yes'
314306

315307
def _enqueue(self, mlist, **_kws):
316-
"""Enqueue the message to the virgin queue."""
317308
# Not imported at module scope to avoid import loop
318309
from Mailman.Queue.sbcache import get_switchboard
319-
virginq = get_switchboard(mm_cfg.VIRGINQUEUE_DIR)
320-
virginq.enqueue(self, listname=mlist.internal_name(), **_kws)
310+
outq = get_switchboard(mm_cfg.OUTQUEUE_DIR)
311+
outq.enqueue(self, {'recipient': self['To'],
312+
'sender': self['From'],
313+
'lang': self.lang,
314+
'mlist': mlist,
315+
'version': mm_cfg.QUEUE_VERSION,
316+
}, **_kws)

0 commit comments

Comments
 (0)