dongzhi6146 2011-06-24 14:36 采纳率: 100%
浏览 89
已采纳

通过电子邮件发送特殊字符给Tumblr

I'm using a PHP script to email a posting to Tumblr and Posterous. For Posterous special characters are showing up in the posting but for Tumblr it don't. (In general Tumblr does support special character - I tried it out with emailing from Gmail) So what could be the problem?

Here my PHP header:

$headers .= "MIME-Version: 1.0
"
           ."Content-Type: multipart/alternative; boundary=\"PHP-mixed-$bound_text\"
";

$message =  "--PHP-mixed-$bound_text
"
           ."Content-Type: multipart/related; type=\"text/html\"; boundary=PHP-mixed2-$bound_text

"
           ."--PHP-mixed2-$bound_text
"
           ."Content-Type: text/html; charset=\"utf-8\"
"
           ."Content-Transfer-Encoding: 7bit

";

I already tried several charsets and Content-Transfer-Encoding combinations without any different result.

Any ideas are welcome. Michael

  • 写回答

1条回答 默认 最新

  • doudang1052 2011-06-24 18:47
    关注

    I looked into how my GMail account sent it and found out it used windows-1252 for the charset and the text is base64 encoded (this may not be case in using other GMail accounts). The email I sent below was successfully posted by tumblr and I used the function utf8_decode to generate the correct base64 string.

    $data = wordwrap(base64_encode(utf8_decode($stringWithSpecialCharacters)));
    

    The raw email message is below:

    To: myuploademail@tumblr.com
    Subject: tumblr post from sudocode
    from: omime class <script@sudocode.net>
    MIME-Version: 1.0
    Content-type: multipart/alternative;
        boundary=omime_1308940625_c0d4e36fd504619028804e8b23ceb12a
    
    
    --omime_1308940625_c0d4e36fd504619028804e8b23ceb12a
    Content-Type: text/plain; charset=windows-1252
    Content-Transfer-Encoding: base64
    
    38TW+eLq7vT76//mP9nCys4=
    --omime_1308940625_c0d4e36fd504619028804e8b23ceb12a
    Content-Type: text/html; charset=windows-1252
    Content-Transfer-Encoding: base64
    
    38TW+eLq7vT76//mP9nCys4=
    --omime_1308940625_c0d4e36fd504619028804e8b23ceb12a--
    

    I used my omime class to send the email and here's the code I used:

    $email = new omime('alternative');
    $email->attachText('ßÄÖùâêîôûëÿæœÙÂÊÎ');
    $email->attachHTML('ßÄÖùâêîôûëÿæœÙÂÊÎ');
    
    $email->send('mysecretuploademail@tumblr.com', 'test tumblr post', 'from: omime class <script@sudocode.net>');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥15 统计大规模图中的完全子图问题
  • ¥15 使用LM2596制作降压电路,一个能运行,一个不能
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题
  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式