Skip to content

[FIX] base: prevent Subject header folding to avoid strict mail server rejections#243119

Closed
Ricardoalso wants to merge 1 commit intoodoo:18.0from
camptocamp:fix_mail_headers_fold
Closed

[FIX] base: prevent Subject header folding to avoid strict mail server rejections#243119
Ricardoalso wants to merge 1 commit intoodoo:18.0from
camptocamp:fix_mail_headers_fold

Conversation

@Ricardoalso
Copy link
Copy Markdown
Contributor

@Ricardoalso Ricardoalso commented Jan 9, 2026

Description of the issue/feature this PR addresses:

Yahoo and other strict mail servers reject emails with 554 Invalid Subject header when Subject headers are folded at 78 characters and contain RFC 2047 encoded-words representing non-ASCII characters.

The issue occurs because:

  1. Long email subjects with accented characters (French: "arrière", "connecté", etc.) are RFC 2047 encoded
  2. Python's email.policy.SMTP folds these headers at 78 characters per RFC 5322 SHOULD recommendation
  3. Yahoo's strict validation rejects folded subjects when the fold occurs at certain positions within or between encoded-words
  4. This results in customer-facing emails being rejected with no delivery failing silently, leading to missed communications.

Current behavior before PR:

Subject: [SOS-1477030] Commande et livraison - Demande de retour - user pseudo 251003-GD1U0E - Cosmo Connected Casque Fusion avec feu =?utf-8?q?arri?==?utf-8?q?=C3=A8re_connect=C3=A9?= et accessoire (#1031590)

This subject:

  • Is 168 characters when unfolded
  • Is folded into 3 lines (78, 74, 60 chars)
  • Contains RFC 2047 encoded "arrière connecté"
  • Is technically RFC 2822 compliant
  • Gets rejected by Yahoo with "554 Invalid Subject header"

While this is technically RFC 2822 compliant, Yahoo's strict validation rejects it.

Python's email.policy.SMTP folds headers at 78 characters to follow RFC 5322's SHOULD recommendation. However, when subjects contain non-ASCII characters that get RFC 2047 encoded, the folding can create patterns that strict mail servers reject.

Desired behavior after PR is merged:

  • No folding of Subject headers, regardless of length
  • Yahoo and all strict SMTP servers accept these emails
  • Customer support emails deliver successfully

I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo
Copy link
Copy Markdown
Contributor

robodoo commented Jan 9, 2026

Pull request status dashboard

@C3POdoo C3POdoo requested review from a team, HydrionBurst and kmagusiak and removed request for a team January 9, 2026 15:39
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line
(up to 998 characters per RFC 5322 MUST requirement).

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.
@Ricardoalso Ricardoalso force-pushed the fix_mail_headers_fold branch from d37e88f to 92a9fe0 Compare January 9, 2026 16:03
@kmagusiak kmagusiak requested review from Julien00859 and removed request for kmagusiak January 9, 2026 16:03
Copy link
Copy Markdown
Contributor

@guewen guewen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm yahoo rejects emails under these conditions, thanks @Ricardoalso for the correction

Copy link
Copy Markdown
Member

@Julien00859 Julien00859 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Yahoo rejects valid emails generated by the standard library of Python, then the problem is on Yahoo's side. Did you try and reach for their own support team?

Don't get me wrong, I hate folding, but I am highly confident that "Subject" of all headers must be folded. I'm pretty sure other "strict" email services are gonna reject our emails if we don't fold the subject.

Also, no test, no merge. I wanna see how the system behave with a long ASCII subject, and another with a long unicode subject (e.g. the french one you got). If we are to merge this one I wanna make sure the unicode one if base64 or %-encoded.

@Julien00859
Copy link
Copy Markdown
Member

fwi @Abridbus @tde-banana-odoo

@guewen
Copy link
Copy Markdown
Contributor

guewen commented Jan 22, 2026

Since we have this problem in production, I'd like to add some context.

Don't get me wrong, I hate folding, but I am highly confident that "Subject" of all headers must be folded. I'm pretty sure other "strict" email services are gonna reject our emails if we don't fold the subject.

Actually, Yahoo is the strict one here. They do respect the RFC, whereas other email providers are more lax.

Here is a real email subjet that is rejected by yahoo once encoded

Re: [SOS-1495488] Commande et livraison - Demande de retour - bibijolie - 251210-AABBCC - Abo actualités digitales 20 semaines d’abonnement à 24 heures, Bilan, Tribune de Genève et tous les titres Tamedia

The bounce message is

<xxxxx@yahoo.com>: host mta7.am0.yahoodns.net[67.195.228.111] said: 554
    Message not accepted. Invalid Subject header. See
    https://senders.yahooinc.com/smtp-error-codes#other-failures (in reply to
    end of DATA command)

The raw header is

Subject: Re: [SOS-1495488] Commande et livraison - Demande de retour -\r\n bibijolie - 251210-AABBCC - Abo =?utf-8?q?actualit=C3=A9s?= digitales 20\r\n semaines =?utf-8?q?d=E2=80=99abonnement_=C3=A0?= 24 heures, Bilan, Tribune de\r\n =?utf-8?q?_?==?utf-8?q?Gen=C3=A8ve?= et tous les titres Tamedia\r\n

With a slight different number of chars

[SOS-1495488] Commande et livraison - Demande de retour - bibijolie - 251210-AABBCC - Abo actualités digitales 20 semaines d’abonnement à 24 heures, Bilan, Tribune de Genève et tous les titres Tamedia

The raw header is the following and is valid

Subject: [SOS-1495488] Commande et livraison - Demande de retour - bibijolie -\r\n 251210-AABBCC - Abo =?utf-8?q?actualit=C3=A9s_digitales_20_semaines_d?=\r\n =?utf-8?q?=E2=80=99abonnement_=C3=A0_24_heures=2C_Bilan=2C_Tribune_de_Gen?=\r\n =?utf-8?q?=C3=A8ve?= et tous les titres Tamedia\r\n

Let's look at what happens in the first, invalid, header.
Zoom here: Tribune de\r\n =?utf-8?q?_?==?utf-8?q?Gen=C3=A8ve?=.
Zoom more: ?==?

Okay, so now let's take a look at https://www.rfc-editor.org/rfc/rfc2047

Ordinary ASCII text and 'encoded-word's may appear together in the
same header field. However, an 'encoded-word' that appears in a
header field defined as '*text' MUST be separated from any adjacent
'encoded-word' or 'text' by 'linear-white-space'.

Where encoded-word is defined as

Generally, an "encoded-word" is a sequence of printable ASCII
characters that begins with "=?", ends with "?=", and has two "?"s in
between.

The encoded words in the header is then actually invalid because it lacks the "linear-white-space", and yahoo's parser respects strictly the RFC. I suppose other parsers are more flexible, but we cannot really blame yahoo on this one, at least we can't really report this to their support.

This is actually a bug in the Python's email standard lib (this is a very complex topic and there is quite a number of issues resolved or not: https://github.com/python/cpython/issues?q=RFC%202047). I could reproduce it this script using only the standard lib: https://gist.github.com/guewen/d240e7d6c1779abeead7a4957d1b4dbe on Python versions 3.13, 3.14 and 3.15dev.

Now regarding

Don't get me wrong, I hate folding, but I am highly confident that "Subject" of all headers must be folded. I'm pretty sure other "strict" email services are gonna reject our emails if we don't fold the subject.

Of course I can't be sure, but I'm not that pessimist about this, because the RFC 5322 (https://datatracker.ietf.org/doc/html/rfc5322#section-2.1.1) states

There are two limits that this specification places on the number of
characters in a line. Each line of characters MUST be no more than
998 characters, and SHOULD be no more than 78 characters, excluding
the CRLF.
The 998 character limit is due to limitations in many implementations
that send, receive, or store IMF messages which simply cannot handle
more than 998 characters on a line. Receiving implementations would
do well to handle an arbitrarily large number of characters in a line
for robustness sake. However, there are so many implementations that
(in compliance with the transport requirements of [RFC5321]) do not
accept messages containing more than 1000 characters including the CR
and LF per line, it is important for implementations not to create
such messages.
The more conservative 78 character recommendation is to accommodate
the many implementations of user interfaces that display these
messages which may truncate, or disastrously wrap, the display of
more than 78 characters per line, in spite of the fact that such
implementations are non-conformant to the intent of this
specification (and that of [RFC5321] if they actually cause
information to be lost). Again, even though this limitation is put
on messages, it is incumbent upon implementations that display
messages to handle an arbitrarily large number of characters in a
line (certainly at least up to the 998 character limit) for the sake
of robustness.

According to this, I see no reason why they would reject a unfolded subject that is less than 998 chars (or 1000 including the final \r\n) but more than 78, it is allowed by the RFC. I tested on gmail, yahoo (despite their strict parser), proton and a couple of others, that accepted the emails.

It is worth noting that the line length section of RFC 5322 that I quoted above applies on all headers, and the implementation in odoo already disables the folding for "message-id", "in-reply-to", "references", "resent-msg-id". I tend to think that if the email parsers in the wild accept these unfolded headers, there is quite a chance they'd accept the subject as well.

Of course, the bug should be fixed in Python's standard lib (still looking if I find a matching issue or if I should create one).

But then, not sure this is going to be corrected soon and patched in all Python versions, so it may be a workaround to remove folding. Let me know if this is something you may consider or not (if it is worth spending time to write the tests).

I would understand if you prefer not to apply the patch as there is no guarantee regarding the compliance of emails servers. Still, I find useful to document what I found in case others experiment the same issues.

@guewen
Copy link
Copy Markdown
Contributor

guewen commented Jan 22, 2026

Python issue: python/cpython#144156

@guewen
Copy link
Copy Markdown
Contributor

guewen commented Jan 27, 2026

For information, we removed the folding of the subject after successful tests on the main email services, running on our production server with success so far.

@Julien00859
Copy link
Copy Markdown
Member

Julien00859 commented Jan 30, 2026

The encoded words in the header is then actually invalid because it lacks the "linear-white-space", and yahoo's parser respects strictly the RFC.

Indeed I see that, thanks for the exact subject line!

I tested on gmail, yahoo (despite their strict parser), proton and a couple of others, that accepted the emails.

Thank for that!

we cannot really blame yahoo on this one, at least we can't really report this to their support.

Actually we could, but just to let them know that emails generated by Python's stdlib are tripping on their validator, with a reference to the Python issue (and maybe this one). We gotta get a higher chance to fix the root issue in Python if many players are complaining about it.

This is actually a bug in the Python's email standard lib (this is a very complex topic and there is quite a number of issues resolved or not: https://github.com/python/cpython/issues?q=RFC%202047).
I could reproduce it this script using only the standard lib: https://gist.github.com/guewen/d240e7d6c1779abeead7a4957d1b4dbe on Python versions 3.13, 3.14 and 3.15dev.

Nice catch, it is not the first time we spot errors in python's email module. Do you know if previous python versions are impacted as well?

@Julien00859
Copy link
Copy Markdown
Member

Julien00859 commented Jan 30, 2026

@Abridbus @tde-banana-odoo @beledouxdenis

I'm done with Python's shitty folding crap, last time we reported a bug (and filled a PR to fix it) we had to wait several years before it got fixed, with no backport. The RFC states "SHOULD be bellow 78, MUST be bellow 998". Here @guewen tested various big email providers, they all seem to accept long (shorter than 998) header. Let's just change the max header length to 998, in master, and merge this PR. What's do you think?

@beledouxdenis
Copy link
Copy Markdown
Contributor

To me I do not believe this is a bad idea, though I have the same reserve as you: Maybe some provider / implementation would reject longer subjects.

Rather than discussing this for months, maybe we can proceed in steps, we first merge this in 19.1 to test the patch on a smaller set of databases, to impact less customers in case there is an issue. if no issue after 2 weeks / a month we proceed with the backport in 18 and previous stable releases.

We can maybe take the opportunity to also add the reply-to, to solve

as that last PR in cpython was not (yet?) backported in the python packages of Debian / Ubuntu.

For information:

from email.message import EmailMessage
from email.policy import SMTP
m = EmailMessage(SMTP.clone(max_line_length=40))
m['reply-to'] = '"Exfiltrator <spy@example.org> (unclosed comment?" <to@example.com>'
print(m.as_string())

In Ubuntu 24.04, with Python 3.12.3, the above outputs

reply-to: Exfiltrator <spy@example.org>
 (unclosed comment? <to@example.com>

While with Python 3.12.12 (e.g. podman run -it --rm python:3.12), the above outputs:

reply-to: "Exfiltrator <spy@example.org>
 (unclosed comment?" <to@example.com>

Notice the double quotes difference.

To me, I do not really care if it's the subject and the reply-to are added in separate PRs or not. My main point would be to do both in 19.1, to reduce the number of impacted production databases in case of issues, and then if no issue arise, backport in stable releases 19, 18 and 17.

@guewen
Copy link
Copy Markdown
Contributor

guewen commented Feb 3, 2026

@Julien00859

Nice catch, it is not the first time we spot errors in python's email module. Do you know if previous python versions are impacted as well?

I just tested on version 3.7 and up, interestingly, it was ok (at least this particular issue) in version 3.7.x to 3.11.x, started misbehaving in 3.12.x. That being said, maybe it was broken in an other way. Details here: python/cpython#144156 (comment)

Some news from our production: we have 12.5k customer service emails sent to our customers on a great range of mailboxes (still with a geographical bias) with the patch and no rejection.

Julien00859 added a commit to odoo-dev/odoo that referenced this pull request Feb 3, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

Co-authored-by: Julien Castiaux <juc@odoo.com>
See-also: odoo#243119
robodoo pushed a commit that referenced this pull request Feb 24, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes #247057

See-also: #243119
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Co-authored-by: Julien Castiaux <juc@odoo.com>
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request Feb 24, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

See-also: odoo#243119
X-original-commit: 368fe4c
Co-authored-by: Julien Castiaux <juc@odoo.com>
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request Feb 24, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

See-also: odoo#243119
X-original-commit: 368fe4c
Co-authored-by: Julien Castiaux <juc@odoo.com>
robodoo pushed a commit that referenced this pull request Feb 25, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes #250388

See-also: #243119
X-original-commit: 368fe4c
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Co-authored-by: Julien Castiaux <juc@odoo.com>
@Julien00859
Copy link
Copy Markdown
Member

Hello @Ricardoalso @guewen, I see that both our PR that changed the folding limit to 1k and the PR in cpython fixing the underlying issues have been merged. Thank you both for your thorough investigation and for testing the patch on your own infrastructure!

I am now closing this PR, thanks!

@guewen
Copy link
Copy Markdown
Contributor

guewen commented Feb 25, 2026

Wow, thanks!

VincentJanssen-Code pushed a commit to odoo-dev/odoo that referenced this pull request Mar 4, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes odoo#250388

See-also: odoo#243119
X-original-commit: 368fe4c
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Co-authored-by: Julien Castiaux <juc@odoo.com>
VincentJanssen-Code pushed a commit to odoo-dev/odoo that referenced this pull request Mar 10, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes odoo#250388

See-also: odoo#243119
X-original-commit: 368fe4c
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Co-authored-by: Julien Castiaux <juc@odoo.com>
Julien00859 added a commit to odoo-dev/odoo that referenced this pull request Mar 10, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

Co-authored-by: Julien Castiaux <juc@odoo.com>
See-also: odoo#243119
VincentJanssen-Code pushed a commit to odoo-dev/odoo that referenced this pull request Mar 10, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes odoo#250388

See-also: odoo#243119
X-original-commit: 368fe4c
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Co-authored-by: Julien Castiaux <juc@odoo.com>
VincentJanssen-Code pushed a commit to odoo-dev/odoo that referenced this pull request Mar 11, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes odoo#250388

See-also: odoo#243119
X-original-commit: 368fe4c
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Co-authored-by: Julien Castiaux <juc@odoo.com>
Julien00859 pushed a commit to odoo-dev/odoo that referenced this pull request Mar 18, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes odoo#250388

See-also: odoo#243119
Backport: odoo#247057
robodoo pushed a commit that referenced this pull request Mar 23, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes #250388

closes #254670

See-also: #243119
Backport: #247057
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request Mar 23, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes odoo#250388

See-also: odoo#243119
Backport: odoo#247057
X-original-commit: cf98058
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request Mar 23, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes odoo#250388

See-also: odoo#243119
Backport: odoo#247057
X-original-commit: cf98058
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request Mar 23, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes odoo#250388

See-also: odoo#243119
Backport: odoo#247057
X-original-commit: cf98058
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request Mar 23, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes odoo#250388

See-also: odoo#243119
Backport: odoo#247057
X-original-commit: cf98058
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request Mar 23, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes odoo#250388

See-also: odoo#243119
Backport: odoo#247057
X-original-commit: cf98058
robodoo pushed a commit that referenced this pull request Mar 23, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes #250388

closes #255383

See-also: #243119
Backport: #247057
X-original-commit: cf98058
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
robodoo pushed a commit that referenced this pull request Mar 23, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes #250388

closes #255302

See-also: #243119
Backport: #247057
X-original-commit: cf98058
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
robodoo pushed a commit that referenced this pull request Mar 23, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes #250388

closes #255425

See-also: #243119
Backport: #247057
X-original-commit: cf98058
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
robodoo pushed a commit that referenced this pull request Mar 23, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes #250388

closes #255413

See-also: #243119
Backport: #247057
X-original-commit: cf98058
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
robodoo pushed a commit that referenced this pull request Mar 24, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes #250388

closes #255352

See-also: #243119
Backport: #247057
X-original-commit: cf98058
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
robodoo pushed a commit that referenced this pull request Mar 24, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes #250388

closes #255352

See-also: #243119
Backport: #247057
X-original-commit: cf98058
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
HazemWaheed2050 pushed a commit to odoo-dev/odoo that referenced this pull request Apr 8, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes odoo#250388

closes odoo#255352

See-also: odoo#243119
Backport: odoo#247057
X-original-commit: cf98058
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Copilot AI pushed a commit to Corvanis/odoo that referenced this pull request Apr 21, 2026
…r rejections

Yahoo and other strict mail servers reject emails with folded Subject headers
containing RFC 2047 encoded-words when the folding occurs at inappropriate
positions, resulting in "554 Invalid Subject header" errors.

The root cause is in Python's stdlib (bpo-144156). In an ideal world we would be
fixing the issue there, but experience tells us that they are very slow to fix
bugs / merge PRs in the email module, and even when they do they usually don't
backport the fixes in the python versions we use.

This commit extends the existing IdentificationFieldsNoFoldPolicy to also
prevent Subject header folding, keeping long subjects on a single line (up to
998 characters per RFC 5322 "MUST" requirement, from the 98 "SHOULD" limit).
Since at it, include the other "user defined" smtp headers: to, from, ...

The solution follows the same pattern already established for identification
headers (Message-ID, In-Reply-To, References) where Odoo prevents folding
to avoid MTAs rewriting these critical headers and breaking email threading.

closes odoo#250388

closes odoo#255425

See-also: odoo#243119
Backport: odoo#247057
X-original-commit: cf98058
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>

Co-authored-by: vvro <8414969+vvro@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants