diff options
| author | Barry Warsaw | 2009-11-02 22:39:40 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2009-11-02 22:39:40 -0500 |
| commit | 83773bbce02e9083f3f427537b9e5bf135f52cd9 (patch) | |
| tree | 041769373b898851eef333d05522717883bc5328 /src | |
| parent | c202caefecbead4c49fbf16ee39461aaef5fa149 (diff) | |
| download | mailman-83773bbce02e9083f3f427537b9e5bf135f52cd9.tar.gz mailman-83773bbce02e9083f3f427537b9e5bf135f52cd9.tar.zst mailman-83773bbce02e9083f3f427537b9e5bf135f52cd9.zip | |
Only personalize when the mailing list requests it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/mailman/mta/docs/personalized.txt | 57 | ||||
| -rw-r--r-- | src/mailman/mta/personalized.py | 4 |
2 files changed, 58 insertions, 3 deletions
diff --git a/src/mailman/mta/docs/personalized.txt b/src/mailman/mta/docs/personalized.txt index c1c590479..4485fd2fc 100644 --- a/src/mailman/mta/docs/personalized.txt +++ b/src/mailman/mta/docs/personalized.txt @@ -22,10 +22,10 @@ Delivery strategies must implement the proper interface. True -To header -========= +No personalization +================== -The To header is replaced with the recipient's address and name. +By default, the To header is not personalized. >>> mlist = create_list('test@example.com') >>> msg = message_from_string("""\ @@ -50,6 +50,57 @@ The To header is replaced with the recipient's address and name. 3 >>> from operator import itemgetter + >>> for message in sorted(messages, key=itemgetter('x-rcptto')): + ... print message.as_string() + ... print '----------' + From: aperson@example.org + To: test@example.com + Subject: test one + Message-ID: <aardvark> + X-Peer: ... + X-MailFrom: test-bounces+aperson=example.com@example.com + X-RcptTo: aperson@example.com + <BLANKLINE> + This is a test. + ---------- + From: aperson@example.org + To: test@example.com + Subject: test one + Message-ID: <aardvark> + X-Peer: ... + X-MailFrom: test-bounces+bperson=example.com@example.com + X-RcptTo: bperson@example.com + <BLANKLINE> + This is a test. + ---------- + From: aperson@example.org + To: test@example.com + Subject: test one + Message-ID: <aardvark> + X-Peer: ... + X-MailFrom: test-bounces+cperson=example.com@example.com + X-RcptTo: cperson@example.com + <BLANKLINE> + This is a test. + ---------- + + +To header +========= + +When the mailing list requests personalization, the To header is replaced with +the recipient's address and name. + + >>> from mailman.interfaces.mailinglist import Personalization + >>> mlist.personalize = Personalization.full + >>> transaction.commit() + + >>> personalized.deliver(mlist, msg, dict(recipients=recipients)) + {} + >>> messages = list(smtpd.messages) + >>> len(messages) + 3 + >>> for message in sorted(messages, key=itemgetter('to')): ... print message.as_string() ... print '----------' diff --git a/src/mailman/mta/personalized.py b/src/mailman/mta/personalized.py index 4d0243fc7..00988d593 100644 --- a/src/mailman/mta/personalized.py +++ b/src/mailman/mta/personalized.py @@ -30,6 +30,7 @@ from email.header import Header from email.utils import formataddr from zope.component import getUtility +from mailman.interfaces.mailinglist import Personalization from mailman.interfaces.usermanager import IUserManager from mailman.mta.verp import VERPDelivery @@ -50,6 +51,9 @@ class PersonalizedMixin: if the recipient is a user registered with Mailman, the recipient's real name too. """ + # Personalize the To header if the list requests it. + if mlist.personalize != Personalization.full: + return recipient = msgdata['recipient'] user_manager = getUtility(IUserManager) user = user_manager.get_user(recipient) |
