On 05/24/2015 12:56 PM, Mark Sapiro wrote:
The code in Mailman 2.1.18+ actually does a DNS lookup of the DMARC policy. In all the myriad @python.org list posts, the only domains I see with p=reject are aol.com, yahoo.com and paypal.com.
If I do this and add the bit about the Reply-To, what would the code look like?
I have attached two files. Cookheaders.py.txt is a patched version of the 2.1.14 CookHeaders which will mung the From: address for messages with a From: containing @yahoo.com or @aol.com in the same way that current Mailman's Mung From action does it.
This would replace your existing Mailman/Handlers/CookHeaders.py, and you also need to remove your changes to Mailman/Handlers/Cleanse.py.
Cookheaders.py.patch.txt is just the diff between the 2.1.14 base CookHeaders.py and the attached Cookheaders.py.txt.
If you want to base the munging on an actual DNS lookup of DMARC policy, you would need to:
Add the IsDMARCProhibited function at lines 1136-1223 at http://bazaar.launchpad.net/~mailman-coders/mailman/2.1/view/head:/Mailman/Utils.py and the import of dns.resolver at lines 74-79 of the same file to your Mailman/Utils.py,
# Parameters for DMARC DNS lookups. If you are seeing 'DNSException: # Unable to query DMARC policy ...' entries in your error log, you may need # to adjust these. # The time to wait for a response from a name server before timeout. DMARC_RESOLVER_TIMEOUT = seconds(3) # The total time to spend trying to get an answer to the question. DMARC_RESOLVER_LIFETIME = seconds(5)
Ensure the dnspython package http://www.dnspython.org/ package is available in Python. This package can be downloaded from dnspython.org or from the CheeseShop https://pypi.python.org/pypi/dnspython/ or installed with pip.
Then you could replace the lines
dre = re.compile('@(yahoo\.com|aol\.com)\W', re.IGNORECASE) if dre.search(msg['from']) and not fasttrack:
in the attached CookHeaders.py.txt with (all one line, watch out for wrap):
if IsDMARCProhibited(mlist, parseaddr(msg.get('from'))) and not