Search code examples
phpzend-frameworkutf-8zend-mail

UTF-8 sender name in Zend_Mail?


I am using Zend_Mail and want to customize the sender name.

I want the sender name to be FooBar爱你Ryan (where 'Ryan' gets replaced with the recipient name and 爱你 gets replaced with the translation for 'loves' in the language of the recipient, just like CD Baby does).

I've tried base64_encode and mb_encode_mimeheader() and other things like:

mb_internal_encoding('UTF-8');
mb_http_output('UTF-8');
iconv_set_encoding("input_encoding", 'UTF-8');
iconv_set_encoding("output_encoding", 'UTF-8');
iconv_set_encoding("internal_encoding", 'UTF-8'); 
header('Content-Type:text/html; charset=' . 'UTF-8');

It generates this as the sender: '=?UTF-8?B?RXh0cmFidXjniLHkvaByY3dhbHNoQGV4dHJhYnV4LmNvbQ==?= <[email protected]>'

And then that appears in my Gmail as (unknown sender).

Any ideas?


Solution

  • I wish I had tried this earlier: when I hard code the Chinese string as the sender name (using utf8 characters), it works fine. (I tested in Gmail only.)

    So the path I'd been going down was mistaken.

    I need to figure out why a dynamically-generated sender name consisting of utf8 characters doesn't work when a hard-coded Chinese string does. But that seems to be a different question.