[issue8989] email.utils.make_msgid: specify domain
Adrian von Bidder added the comment: On Thursday 02 December 2010 22.51:51 you wrote: > Committed to py3k in r86936 with minor fixups. thanks, great! (Wheee! my first patch to Python ;-) cheers -- vbi -- ___ Python tracker <http://bugs.python.org/issue8989> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8989] email.utils.make_msgid: specify domain
Adrian von Bidder added the comment: I'm sure several of you have worked with the Python source code before and know by heart how to run the testsuite. In other words: I admit that I've only written the code and have not tried it. Given how trivial the patch is, I have some hope ;-) -- Added file: http://bugs.python.org/file17668/make_msgid-domain.diff ___ Python tracker <http://bugs.python.org/issue8989> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8989] email.utils.make_msgid: specify domain
Adrian von Bidder added the comment: Thanks for the positive feedback. I'll try to do the diff against top of tree and the unit test soon-ish. Use case: * In my specific case, I'm writing a sort of cross between mailing list and blog system and I'd like to use a static (across all installations) domain for internally generated messages. * kmail offers the choice of custom domain for message-id as well, I've set it to my own domain for ages. It turns out that message-ids are harvested by spammers and so I've got a quite good way to build spamtraps since "nobody" will ever try to send real email to these "adresses". (Or, in the reverse case: if your host's fqdn is a valid email domain you may actually not want to cause this kind of load to your MX.) (Not sure if this should be added to the documentation, though. The explanation seems much too long in comparision with the complexity of the feature.) -- ___ Python tracker <http://bugs.python.org/issue8989> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8989] email.utils.make_msgid: specify domain
New submission from Adrian von Bidder : Using the hostname for the domain part of a Message-Id is probably the right thing usually but users may want to override this. Please consider this rather trivial patch: = --- utils.py.orig 2010-06-13 16:59:30.533861099 +0200 +++ utils.py2010-06-13 17:02:18.650697979 +0200 @@ -173,13 +173,15 @@ -def make_msgid(idstring=None): +def make_msgid(idstring=None, domain=None): """Returns a string suitable for RFC 2822 compliant Message-ID, e.g: <20020201195627.33539.96...@nightshade.la.mastaler.com> Optional idstring if given is a string used to strengthen the -uniqueness of the message id. +uniqueness of the message id. The domain part of the Message-ID +defaults to the locally defined hostname, but can be specified +explicitly. """ timeval = time.time() utcdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(timeval)) @@ -189,8 +191,9 @@ idstring = '' else: idstring = '.' + idstring -idhost = socket.getfqdn() -msgid = '<%s.%s.%...@%s>' % (utcdate, pid, randint, idstring, idhost) +if domain is None: +domain = socket.getfqdn() +msgid = '<%s.%s.%...@%s>' % (utcdate, pid, randint, idstring, domain) return msgid = thanks & greetings -- vbi -- components: Library (Lib) messages: 107734 nosy: avbid...@fortytwo.ch priority: normal severity: normal status: open title: email.utils.make_msgid: specify domain versions: Python 2.6, Python 3.1 ___ Python tracker <http://bugs.python.org/issue8989> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com