laminas-mail icon indicating copy to clipboard operation
laminas-mail copied to clipboard

\Zend\Mail\Header\HeaderValue should support unicode characters

Open michalbundyra opened this issue 6 years ago • 6 comments

This issue has been moved from the zendframework repository as part of the bug migration program as outlined here - http://framework.zend.com/blog/2016-04-11-issue-closures.html


Original Issue: https://api.github.com/repos/zendframework/zendframework/issues/7656 User: @akosphp Created On: 2016-01-02T14:42:06Z Updated At: 2016-02-13T15:34:17Z Body The isValid method doesn't support unicode characters in the header value. This is a problem for example when unicode email address is given. (eg.: üñîçøðé@example.com - which is a valid email address)

Unicode email addresses cause Zend\Mail\Header\Exception\RuntimeException in vendor\zendframework\zend-mail\src\Header\HeaderValue.php:115 Exception message: Invalid header value detected.



Originally posted by @GeeH at https://github.com/zendframework/zend-mail/issues/96

michalbundyra avatar Jan 15 '20 19:01 michalbundyra

Any known workarounds for this issue?


Originally posted by @chadabaker at https://github.com/zendframework/zend-mail/issues/96#issuecomment-519491891

michalbundyra avatar Jan 15 '20 19:01 michalbundyra

Read https://docs.zendframework.com/zend-mail/message/intro/ and just use correct encoding.


Originally posted by @coder-pm at https://github.com/zendframework/zend-mail/issues/96#issuecomment-525195463

michalbundyra avatar Jan 15 '20 19:01 michalbundyra

Any news on this ? Patch? Workaround ?

smsalert-mobi avatar Mar 07 '22 18:03 smsalert-mobi

@smsalert-mobi send one 👍

Ocramius avatar Mar 07 '22 18:03 Ocramius

Any news on this ? Patch? Workaround ?

@smsalert-mobi please set encoding: https://docs.laminas.dev/laminas-mail/message/character-sets/

coder-pm avatar Mar 08 '22 07:03 coder-pm

Any news on this ? Patch? Workaround ?

@smsalert-mobi please set encoding: https://docs.laminas.dev/laminas-mail/message/character-sets/

you can't when using IMAP / POP3 this fails as soon you are trying to iterate over inbox

a workaround is not to Iterate over imap / pop3 (built in) and do a for loop, this way you can use try / catch per message and ignore the "invalid" ones.

   $mail = new Imap([
        'host'     => '',
        'user'     => '',
        'password' => '',
        'ssl'      => 'ssl',
    ]);

    for ($index = 1; $index <= $mail->countMessages(); $index++) {
        try {
            $messageStorage = $mail->getMessage($index);
        } catch (\Exception $e) {
            //
        }
     }

smsalert-mobi avatar Mar 08 '22 11:03 smsalert-mobi