PHP 电子邮件编码? [英] PHP E-Mail Encoding?

查看:34
本文介绍了PHP 电子邮件编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在发送电子邮件时遇到一些外来字符的问题.有人可以建议我该怎么做吗?我怀疑问题可能是三件事之一.

I am having some trouble with foreign characters when sending an e-mail. Could someone advise me on what to do? I suspect the problem could be one of three things.

  1. html 页面编码不正确.(这会影响表单中的 POST 数据吗?)
  2. 邮件功能没有任何编码.因此程序不知道如何读取它.(最有可能)
  3. 文件本身没有正确的编码,因此会出现问题.(可能不太可能)

还有其他可能的原因吗?

Are there any other possible causes?

我正在尝试一一解决这些问题,直到找到问题为止.我认为选项 2 是最可能的原因.如何为邮件功能添加正确的通用编码?

I am trying to knock these out 1 by 1 until I find the problem. I think that option 2 is the most likely cause. How do I add proper - universal encoding to a mail function?

这就是我目前所拥有的.

This is what I have at the moment.

$mail_sent = mail($client_email, $title, $message, "From: {$visitor_email}");

我目前知道该表单不会发送波兰语或瑞典语字符.

I am currently aware that form does not send polish or Swedish characters.

如果有人能指出任何其他可能的原因并告诉我发送电子邮件需要使用什么编码,我将不胜感激.

I would be very grateful if someone could point out any other possible causes and tell me what encoding I need to use to send e-mails.

非常感谢.

推荐答案

据我所知,PHP 不支持 UTF-8 作为其字符串的默认编码.您需要为您喜欢的编码使用相关的编码/处理函数.

As far as I know PHP does not support UTF-8 as default encoding for its strings. You need to use the relevant encoding/handling functions for the encoding you would prefer.

还要将 Content-Type:text/html;charset=utf-8 添加到您的电子邮件标头,以便电子邮件客户端正确显示字符(或替换为您选择的编码).

Also add a Content-Type:text/html;charset=utf-8 to your email headers so the email clients will display the characters correctly (or replace with your encoding of choice).

这篇关于PHP 电子邮件编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆