python / python/cpython

email.utils.make_msgid return ids that break email messages with related content

Open
#100,293 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs topic-email type-bug
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Bug report

I have been trying to replicate the examples listed here: https://docs.python.org/3/library/email.examples.html

For some reason the one about "creating an HTML message with an alternative plain text version" is assembling an email message that Thunderbird (and other email readers) does not display correctly, as images are not displayed and marked as broken.

The example uses make_msgid() to generate content ids.

Python 3.10.9 (main, Dec  7 2022, 03:14:04) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from email import utils
>>> utils.make_msgid()
'<167119948916.50921.14529814791249370642@1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa>'
>>>

Turns out that for some reason the string is too long, because if I either remove the domain part or purportedly shorten it, e.g., make_msgid(domain="0.0.0.ip6.arpa"), then everything works again and the resulting email can be correctly displayed in Thunderbird/Outlook.

Your environment

  • CPython versions tested on: 3.10.9
  • Operating system and architecture: OSX/M1
Linked PRs
  • gh-100856

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Thunderbird/Outlook failure from the email.examples.html example and inspect email.utils.make_msgid(), especially with its default domain. Compare the generated content IDs with the shortened-domain case; done means the example produces related-content messages that email readers display correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.