我的PHP应用程序处理收到的电子邮件。处理代码通常运行良好,但该应用程序最近崩溃,只有以下例外:
Unexpected encoding - UTF-8 or ASCII was expected (View: /home/customer/www/gonativeguide.com/gng2-core/vendor/laravel/framework/src/Illuminate/Mail/resources/views/html/panel.blade.php) {"exception":"[object] (Facade\\Ignition\\Exceptions\\ViewException(code: 0): Unexpected encoding - UTF-8 or ASCII was expected (View: /home/customer/www/gonativeguide.com/gng2-core/vendor/laravel/framework/src/Illuminate/Mail/resources/views/html/panel.blade.php) at /home/customer/www/gonativeguide.com/gng2-core/vendor/league/commonmark/src/Input/MarkdownInput.php:30)
似乎有一封收到的电子邮件的文本没有被正确地解码,这使得应用程序后来崩溃。
我意识到这封电子邮件的编码是Windows-1252:
Content-Type: text/html; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
电子邮件解码代码当前如下所示:
// DECODE DATA
$data = ($partno)?
imap_fetchbody($mbox,$mid,$partno): // multipart