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

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

问题描述

发送电子邮件时,我遇到外国人的麻烦。有人可以建议我该怎么办我认为问题可能是三件事之一。

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

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

1) The html page encoding is incorrect. (Would this affect the POST data from the form?) 2) The mail function doesn't have any encoding. Thus the program doesn't know how to read it. (Most likely) 3) The file itself doesn't have the right encoding and thus is making problems. (Probably quite unlikely)

是否有其他可能的原因?

Are there any other possible causes?

我试图敲出这些1一直到我找到问题。我认为选项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?

这是我目前所拥有的。

$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天全站免登陆