dqhsv0147421 2015-07-21 15:13
浏览 45

邮件模板编码突然出错了。 似乎只能手动重写。 一些提示,知识?

I have a problem with our E-Mail templates. They worked fine until 2-3 days ago i have no idea what happened.

They should be utf8 encoded and get shown correctly in PHP Storm they look something like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body {
    ....
}
</style
</head>
<body>
    <center>Content with unique characters like ěäüß</center>
</body>
</html>

But in the Email the output is completely rubbish:
Vaše zakázka etc.

I use the output buffer to get the template content and send it with PHPMailer. There is no encoding anywhere but shouldn't be needed.
I tried utf8-encode/decode etc. It makes everything only worse. The only thing that worked is to use tools like this http://www.percederberg.net/tools/text_converter.html
to convert the plain text into utf-8 and then the code looks like rubbish like in the mail output, but then you can manually correct every character.. that worked for some templates like in german with some äüß.... but in the Czech template you have to rewrite every single character.

Is there something that i missed? Something that i could try?

  • 写回答

1条回答 默认 最新

  • dqjo4340 2015-07-22 08:54
    关注

    I used htmlentities() on the text parts of the templates and worked quite decent!

    Example:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
    body {
        ....
    }
    </style
    </head>
    <body>
        <center><?php echo htmlentities("Content with unique characters like ěäüß"); ?></center>
    </body>
    

    Hope this helps someone!

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?