You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mailbox: It would be nice to move mailbox.Message from legacy email.message.Message API to new EmailMessage API #77156
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2018-03-01.05:44:18.590>labels= ['type-feature', '3.8', 'expert-email']
title='mailbox: It would be nice to move mailbox.Message from legacy email.message.Message API to new EmailMessage API'updated_at=<Date2018-03-02.02:29:36.775>user='https://github.com/maxking'
Since Python 3.6 the new EmailMessage API seems to be the default but mailbox.Message still subclasses from the old email.message.Message API.
It would be nice to get EmailMessage from mailbox so that one can rely on the new methods and content managers. Also, while it is possible to pass a constructor to mailbox.mbox to get the new EmailMessage style message, it is different from mailbox.Message which has some extra methods.
I should also mention probably that I went ahead and made changes to make this work and I can pass most of the tests, one is failing due to missing \n character in the header's value obtained from msg.get_all('Received').
I can make a pull request on Github if that would be a good place to start the discussion instead.
This is a reasonable request (a good way to use EmailMessage), but EmailMessage is not yet the default even for the email package. You have to specify policy=default to get it (or use it to construct a message).
Mailbox probably needs some backward compatible way for the user to specify the policy.
Activity
maxking commentedon Mar 1, 2018
Since Python 3.6 the new EmailMessage API seems to be the default but mailbox.Message still subclasses from the old email.message.Message API.
It would be nice to get EmailMessage from mailbox so that one can rely on the new methods and content managers. Also, while it is possible to pass a constructor to mailbox.mbox to get the new EmailMessage style message, it is different from mailbox.Message which has some extra methods.
maxking commentedon Mar 1, 2018
I should also mention probably that I went ahead and made changes to make this work and I can pass most of the tests, one is failing due to missing
\ncharacter in the header's value obtained frommsg.get_all('Received').I can make a pull request on Github if that would be a good place to start the discussion instead.
bitdancer commentedon Mar 2, 2018
This is a reasonable request (a good way to use EmailMessage), but EmailMessage is not yet the default even for the email package. You have to specify policy=default to get it (or use it to construct a message).
Mailbox probably needs some backward compatible way for the user to specify the policy.
maxking commentedon Mar 2, 2018
Can you suggest what would be the best way go about doing that?
Given that mailbox.Message subclasses from Message, I am not sure how to proceed about this to make this configurable with a flag.
I haven't yet made a PR, but this1 is the URL to the change I made.
takeda commentedon Jun 30, 2024
Are there any plans to fix that? It feels like this was overlooked by whomever was working on the improved message.
I'm wondering if there's any workaround to use the new EmailMessage? for example is it acceptable to pass it as a factory or is there a better way?