Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TO_EXCESS_QP warning from RSPAMD or SpamAssassin #222

Open
bupy7 opened this issue Dec 8, 2022 · 2 comments
Open

TO_EXCESS_QP warning from RSPAMD or SpamAssassin #222

bupy7 opened this issue Dec 8, 2022 · 2 comments
Labels
Bug Something isn't working

Comments

@bupy7
Copy link

bupy7 commented Dec 8, 2022

Bug Report

Version: 2.14.1

Summary

For example, we have the follows code:

$builder = new \Laminas\Mail\Message();
$builder->setEncoding('UTF-8');

$builder->setFrom(['[email protected]' => 'Sender Name']);
$builder->setTo(['[email protected]' => 'Recipient Name']);

From and To headers will looks like:

From: =?UTF-8?Q?Sender=20Name?= <[email protected]>\r\n
To: =?UTF-8?Q?Recipient=20Name?= <[email protected]>\r\n

But some email validation services (RSPAMD or SpamAssassin) gives to us a warning "TO_EXCESS_QP: To that contains encoded characters while quoted-printable is not needed as all symbols are 7bit", because the strings "Sender Name" and "Recipient Name" has ASCII compatibility already. So, without direct fix in Laminas\Mail\Header\AbstractAddressList::getFieldValue() has no any ability do not encode those strings always.

I would like do not encode ASCII compatibility strings without any reasons.

From: Sender Name <[email protected]>\r\n
To: Recipient Name <[email protected]>\r\n

Therefore, I think, the fix should looks like

public function getFieldValue($format = HeaderInterface::FORMAT_RAW)
{
    // ...
    
    if (!empty($name) && preg_match('/^[[:ascii:]]+$/', $name) !== 1) {
        $name = HeaderWrap::mimeEncodeValue($name, $encoding);
    }
    
    // ...

The same problem was in Symphony CMS symphonycms/symphonycms#2858

Current behavior

Name of email encode always.

How to reproduce

See summary section.

Expected behavior

Do not encode name of email without necessary.

@bupy7 bupy7 added the Bug Something isn't working label Dec 8, 2022
@Slamdunk
Copy link
Contributor

Hi, can you propose a PR with a correlated test for this?
That would be very much appreciated 💪

@bupy7
Copy link
Author

bupy7 commented Jan 15, 2023

@Slamdunk Hi!
I would like to, but the problem is not at To/From headers only. For the other headers the encoding may be not necessary either. HeaderWrap::mimeEncodeValue() using by many different places, therefore, the library need to refactor the all. It's a big work and, for some reasons, the better option will use the PHPMailer library, that respect necessary of encoding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants