Fully personalized delivery

Fully personalized mail delivery is an enhancement over VERP delivery where the To: field of the message is replaced with the recipient’s address. A typical email message is sent to the mailing list’s posting address and copied to the list membership that way. Some people like the more personal address.

Personalized delivery still does VERP.

>>> from mailman.mta.personalized import PersonalizedDelivery
>>> personalized = PersonalizedDelivery()

Delivery strategies must implement the proper interface.

>>> from mailman.interfaces.mta import IMailTransportAgentDelivery
>>> from zope.interface.verify import verifyObject
>>> verifyObject(IMailTransportAgentDelivery, personalized)
True

No personalization

By default, the To: header is not personalized.

>>> mlist = create_list('[email protected]')
>>> msg = message_from_string("""\
... From: [email protected]
... To: [email protected]
... Subject: test one
... Message-ID: <aardvark>
...
... This is a test.
... """)

>>> recipients = set([
...     '[email protected]',
...     '[email protected]',
...     '[email protected]',
...     ])

>>> personalized.deliver(mlist, msg, dict(recipients=recipients))
{}
>>> messages = list(smtpd.messages)
>>> len(messages)
3

>>> from operator import itemgetter
>>> for message in sorted(messages, key=itemgetter('x-rcptto')):
...     print(message.as_string())
...     print('----------')
From: [email protected]
To: [email protected]
Subject: test one
Message-ID: <aardvark>
X-Peer: ...
X-MailFrom: [email protected]
X-RcptTo: [email protected]

This is a test.
----------
From: [email protected]
To: [email protected]
Subject: test one
Message-ID: <aardvark>
X-Peer: ...
X-MailFrom: [email protected]
X-RcptTo: [email protected]

This is a test.
----------
From: [email protected]
To: [email protected]
Subject: test one
Message-ID: <aardvark>
X-Peer: ...
X-MailFrom: [email protected]
X-RcptTo: [email protected]

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('----------')
From: [email protected]
To: [email protected]
Subject: test one
Message-ID: <aardvark>
X-Peer: ...
X-MailFrom: [email protected]
X-RcptTo: [email protected]

This is a test.
----------
From: [email protected]
To: [email protected]
Subject: test one
Message-ID: <aardvark>
X-Peer: ...
X-MailFrom: [email protected]
X-RcptTo: [email protected]

This is a test.
----------
From: [email protected]
To: [email protected]
Subject: test one
Message-ID: <aardvark>
X-Peer: ...
X-MailFrom: [email protected]
X-RcptTo: [email protected]

This is a test.
----------

If the recipient is a user registered with Mailman, and the user has an associated real name, then this name also shows up in the To: header.

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

>>> bill = user_manager.create_user('[email protected]', 'Bill Person')
>>> cate = user_manager.create_user('[email protected]', 'Cate Person')
>>> transaction.commit()

>>> personalized.deliver(mlist, msg, dict(recipients=recipients))
{}
>>> messages = list(smtpd.messages)
>>> len(messages)
3

>>> from operator import itemgetter
>>> for message in sorted(messages, key=itemgetter('x-rcptto')):
...     print(message.as_string())
...     print('----------')
From: [email protected]
To: [email protected]
Subject: test one
Message-ID: <aardvark>
X-Peer: ...
X-MailFrom: [email protected]
X-RcptTo: [email protected]

This is a test.
----------
From: [email protected]
To: Bill Person <[email protected]>
Subject: test one
Message-ID: <aardvark>
X-Peer: ...
X-MailFrom: [email protected]
X-RcptTo: [email protected]

This is a test.
----------
From: [email protected]
To: Cate Person <[email protected]>
Subject: test one
Message-ID: <aardvark>
X-Peer: ...
X-MailFrom: [email protected]
X-RcptTo: [email protected]

This is a test.
----------