diff options
| author | Barry Warsaw | 2016-07-16 15:44:07 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2016-07-16 15:44:07 -0400 |
| commit | dbde6231ec897379ed38ed4cd015b8ab20ed5fa1 (patch) | |
| tree | 1226d06a238314262a1d04d0bbf9c4dc0b72c309 /src/mailman/app/bounces.py | |
| parent | 3387791beb7112dbe07664041f117fdcc20df53d (diff) | |
| download | mailman-dbde6231ec897379ed38ed4cd015b8ab20ed5fa1.tar.gz mailman-dbde6231ec897379ed38ed4cd015b8ab20ed5fa1.tar.zst mailman-dbde6231ec897379ed38ed4cd015b8ab20ed5fa1.zip | |
Diffstat (limited to 'src/mailman/app/bounces.py')
| -rw-r--r-- | src/mailman/app/bounces.py | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/mailman/app/bounces.py b/src/mailman/app/bounces.py index 977b21038..98076dc9b 100644 --- a/src/mailman/app/bounces.py +++ b/src/mailman/app/bounces.py @@ -32,9 +32,9 @@ from mailman.interfaces.bounce import UnrecognizedBounceDisposition from mailman.interfaces.listmanager import IListManager from mailman.interfaces.pending import IPendable, IPendings from mailman.interfaces.subscriptions import ISubscriptionService +from mailman.interfaces.template import ITemplateLoader from mailman.utilities.email import split_email -from mailman.utilities.i18n import make -from mailman.utilities.string import oneline +from mailman.utilities.string import expand, oneline, wrap from string import Template from zope.component import getUtility from zope.interface import implementer @@ -184,12 +184,19 @@ def send_probe(member, msg): """ mlist = getUtility(IListManager).get_by_list_id( member.mailing_list.list_id) - text = make('probe.txt', mlist, member.preferred_language.code, - listname=mlist.fqdn_listname, - address=member.address.email, - optionsurl=member.options_url, - owneraddr=mlist.owner_address, - ) + template = getUtility(ITemplateLoader).get( + 'list:user:notice:probe', mlist, + language=member.preferred_language.code, + # For backward compatibility. + code=member.preferred_language.code, + ) + text = wrap(expand(template, mlist, dict( + sender_email=member.subscriber.email, + # For backward compatibility. + address=member.address.email, + email=member.address.email, + owneraddr=mlist.owner_address, + ))) message_id = msg['message-id'] if isinstance(message_id, bytes): message_id = message_id.decode('ascii') @@ -240,11 +247,11 @@ def maybe_forward(mlist, msg): # The notification is either going to go to the list's administrators # (owners and moderators), or to the site administrators. Most of the # notification is exactly the same in either case. - adminurl = mlist.script_url('admin') + '/bounce' subject = _('Uncaught bounce notification') - text = MIMEText( - make('unrecognized.txt', mlist, adminurl=adminurl), - _charset=mlist.preferred_language.charset) + template = getUtility(ITemplateLoader).get( + 'list:admin:notice:unrecognized', mlist) + text = expand(template, mlist) + text_part = MIMEText(text, _charset=mlist.preferred_language.charset) attachment = MIMEMessage(msg) if (mlist.forward_unrecognized_bounces_to is UnrecognizedBounceDisposition.administrators): @@ -258,6 +265,6 @@ def maybe_forward(mlist, msg): # Create the notification and send it. notice = OwnerNotification(mlist, subject, **keywords) notice.set_type('multipart/mixed') - notice.attach(text) + notice.attach(text_part) notice.attach(attachment) notice.send(mlist) |
