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

Can not send email because of failing mb_encode_mimeheader #567

Open
blummarci24 opened this issue Nov 7, 2024 · 1 comment
Open

Can not send email because of failing mb_encode_mimeheader #567

blummarci24 opened this issue Nov 7, 2024 · 1 comment
Labels
Type: Bug Something isn't working

Comments

@blummarci24
Copy link

Issue

There is a failing code in the legacy Localization.php in translateCharsetMIME function causing error on email sending.

The failing code is here:

$result = mb_encode_mimeheader($string, $toCharset, $encoding);

Digging deeper it is a change in polyfill-mbstring dependency:

```public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
{
    trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', \E_USER_WARNING);
}```

Possible Fix

As suggested, use iconv_mime_encode. I have a working local solution for this which fix this issue.

    public function translateCharsetMIME($string, $fromCharset, $toCharset = 'UTF-8', $encoding = "Q")
    {
        $preferences = array(
            'input-charset' => $fromCharset,
            'output-charset' => $toCharset,
            'line-length' => 76,
            'scheme' => $encoding,
            'line-break-chars' => "\n"
        );
        $result = iconv_mime_encode('', $string, $preferences);
        return substr($result, 2);
    }
    
    ```
    
    I will create a PR for this.

### Steps to Reproduce the Issue

```bash
1. Set up an new suitecrm environment (tested on 8.7 and php 8.2)
2. Login and go to admin page
3. Configure email and try to send a test email
...

Context

I tried the email functionality. I have not found any other topic to this certain issue, so I took a look at the code.

Version

8.7.0

What browser are you currently using?

Chrome

Browser Version

No response

Environment Information

PHP 8.2

Operating System and Version

Ubuntu 20.04.6 LTS

@blummarci24 blummarci24 added the Type: Bug Something isn't working label Nov 7, 2024
blummarci24 added a commit to blummarci24/SuiteCRM-Core that referenced this issue Nov 8, 2024
@blummarci24
Copy link
Author

Fix in:

#568

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

No branches or pull requests

1 participant