问题
I just encountered an error in an older script (using Zend 1):
This is part of an email:
--_008_AM2PR07MB0610CE26A6AB7483C300DDC0F4620AM2PR07MB0610eurp_
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document;
name="=?utf-8?B?VmVydHJhdWxpY2hrZWl0c2Vya2zDpHJ1bmdfTGllZmVyYW50ZW5fYmxhbmtv?=
=?utf-8?Q?.docx?="
Content-Description: =?utf-8?B?VmVydHJhdWxpY2hrZWl0c2Vya2zDpHJ1bmdfTGllZmVyYW50ZW5fYmxhbmtv?=
=?utf-8?Q?.docx?=
Content-Disposition: attachment;
filename="=?utf-8?B?VmVydHJhdWxpY2hrZWl0c2Vya2zDpHJ1bmdfTGllZmVyYW50ZW5fYmxhbmtv?=
=?utf-8?Q?.docx?="; size=29798;
creation-date="Wed, 10 Dec 2014 15:04:14 GMT";
modification-date="Wed, 10 Dec 2014 15:04:14 GMT"
Content-Transfer-Encoding: base64
But my code is failing with this:
exception 'Zend_Mail_Exception' with message 'Invalid header value detected [application/vnd.openxmlformats-officedocument.wordprocessingml.document; name="Vertraulichkeitserklärung_Lieferanten_blanko.docx"]' in /usr/share/php/Zend/Mail/Header/HeaderValue.php:133
Stack trace:
#0 /usr/share/php/Zend/Mail/Part.php(600): Zend_Mail_Header_HeaderValue::assertValid('application/vnd...')
#1 /usr/share/php/Zend/Mail/Part.php(151): Zend_Mail_Part->_validateHeaders(Array)
#2 /usr/share/php/Zend/Mail/Part.php(289): Zend_Mail_Part->__construct(Array)
#3 /usr/share/php/Zend/Mail/Part.php(353): Zend_Mail_Part->_cacheContent()
#4 /root/gmail_backup/Searcher.php(241): Zend_Mail_Part->countParts()
As you can see the name of the file is with a special character (ä).
How would I be able to say this header is correct? (so that Zend_Mail_Header_HeaderValue::isValid returns true instead of false?)
UPDATE 1: my iconv.internal_encoding was set to ISO-8859-1, I set it now to UTF-8.
Thanks!
来源:https://stackoverflow.com/questions/35926128/zend-mail-header-headervalueisvalid-is-not-valid-with-special-characters