diff options
author | R. David Murray <rdmurray@bitdance.com> | 2010-12-02 21:47:19 (GMT) |
---|---|---|
committer | R. David Murray <rdmurray@bitdance.com> | 2010-12-02 21:47:19 (GMT) |
commit | a0b44b5adb05e96e68297adcba39985b8f4dee61 (patch) | |
tree | 1015b86932a3a58250e2833d8fec977671eddf04 /Lib/email/utils.py | |
parent | 52173d4959a1c1e961efab2522e4ba8a22a3c7c6 (diff) | |
download | cpython-a0b44b5adb05e96e68297adcba39985b8f4dee61.zip cpython-a0b44b5adb05e96e68297adcba39985b8f4dee61.tar.gz cpython-a0b44b5adb05e96e68297adcba39985b8f4dee61.tar.bz2 |
#8989: add 'domain' keyword to make_msgid.
Patch by Adrian von Bidder.
Diffstat (limited to 'Lib/email/utils.py')
-rw-r--r-- | Lib/email/utils.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/email/utils.py b/Lib/email/utils.py index 5f40bac..ac4da37 100644 --- a/Lib/email/utils.py +++ b/Lib/email/utils.py @@ -148,13 +148,15 @@ def formatdate(timeval=None, localtime=False, usegmt=False): -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.96671@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. Optional domain if given provides the + portion of the message id after the '@'. It defaults to the locally + defined hostname. """ timeval = time.time() utcdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(timeval)) @@ -164,8 +166,9 @@ def make_msgid(idstring=None): idstring = '' else: idstring = '.' + idstring - idhost = socket.getfqdn() - msgid = '<%s.%s.%s%s@%s>' % (utcdate, pid, randint, idstring, idhost) + if domain is None: + domain = socket.getfqdn() + msgid = '<%s.%s.%s%s@%s>' % (utcdate, pid, randint, idstring, domain) return msgid |