Returns a string suitable for RFC 2822 compliant Message-ID, e.g: <142480216486.20800.16526388040877946887@nightshade.la.mastaler.com> Optional idstring if given is a string used to strengthen the uniqueness of the message id. Optional domain if given provides the portion of the m
(idstring=None, domain=None)
| 285 | |
| 286 | |
| 287 | def make_msgid(idstring=None, domain=None): |
| 288 | """Returns a string suitable for RFC 2822 compliant Message-ID, e.g: |
| 289 | |
| 290 | <142480216486.20800.16526388040877946887@nightshade.la.mastaler.com> |
| 291 | |
| 292 | Optional idstring if given is a string used to strengthen the |
| 293 | uniqueness of the message id. Optional domain if given provides the |
| 294 | portion of the message id after the '@'. It defaults to the locally |
| 295 | defined hostname. |
| 296 | """ |
| 297 | # Lazy imports to speedup module import time |
| 298 | # (no other functions in email.utils need these modules) |
| 299 | import random |
| 300 | import socket |
| 301 | |
| 302 | timeval = int(time.time()*100) |
| 303 | pid = os.getpid() |
| 304 | randint = random.getrandbits(64) |
| 305 | if idstring is None: |
| 306 | idstring = '' |
| 307 | else: |
| 308 | idstring = '.' + idstring |
| 309 | if domain is None: |
| 310 | domain = socket.getfqdn() |
| 311 | msgid = '<%d.%d.%d%s@%s>' % (timeval, pid, randint, idstring, domain) |
| 312 | return msgid |
| 313 | |
| 314 | |
| 315 | def parsedate_to_datetime(data): |
searching dependent graphs…