以及PHP电子邮件问题

时间:2013-08-22 00:03:29

标签: php html-email

  

I'm using   but getting � on my email. How can I fix this?

代码的某些部分:

    $review = "
        <table width='100%' border='0'>
        <tr>
            <td class='text_font' >Customer Name:&nbsp;&nbsp; $account_nam</td>
        </tr>
        </table>";

显示为

客户名称: 样本帐户名称

还有这个:

  

<td width='20%' style='border-bottom: 1px solid #CECECE;'></td>

<td>没有价值但显示有趣的符号

3 个答案:

答案 0 :(得分:1)

我猜你的编码是UTF-8,而邮件客户端是ISO,反之亦然。 请务必在邮件标题中发送正确的编码。

使用空白空间生成边距无论如何都不是一个好主意,为什么不将表格单元格用于字段和值:

$review = "
    <table width='100%' border='0'>
    <tr>
        <td class='text_font' >Customer Name:</td>
        <td>" . $account_name . "</td>
    </tr>
    </table>";

答案 1 :(得分:0)

很可能是编码问题。您正在使用的编辑器上的设置可能是以某些无法识别的编码保存文本。我使用notepad ++时遇到过类似的问题而没有考虑编码。

答案 2 :(得分:0)

您有可能从MS Word导入文本。 Word有一些时髦的字符,如有角度的引号等。

你可以在评论中使用htmlentities作为Daryl建议,但我在过去发现你必须像这样str_replace这些字符:

$text = str_replace("&ldquo;", '"', $text);
$text = str_replace("&rdquo;", '"', $text);
$text = str_replace("&lsquo;", "'", $text);
$text = str_replace("&rsquo;", "'", $text);
$text = str_replace("&hellip;", '...', $text);
$text = str_replace("&ndash;", '-', $text);