=?UTF-8?B ?? =在通过php邮件问题发送的电子邮件中 [英] =?UTF-8?B??= in Emails sent via php mail problem

查看:199
本文介绍了=?UTF-8?B ?? =在通过php邮件问题发送的电子邮件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,在联系部分我有一个用户可以填写的表单与我联系。
表单是一个简单的表单,该操作是一个php页面。



PHP代码:

  $ to =email@domain.com; 

$ name = $ _ POST ['name']; //发件人名称
$ email = $ _ POST ['email']; //发件人电子邮件
$ tel = $ _POST ['tel']; // sender tel
$ subject = $ _ POST ['subject']; // subject CHOSEN FROM DROPLIST,ALL TESTED
$ text = $ _ POST ['text']; //来自发件人的消息
$ text。=\\\
\\\
Tel:$ tel; //添加到消息中,向消息的底部显示电话nr给发件人

$ headers =MIME-Version:1.0。\\\
;
$ headers。=Content-type:text / plain; charset = UTF-8。\\\
;
$ headers。=From:$ name< $ email>。\\\
;

mail($ to,'=?UTF-8?B?'。base64_encode($ subject)。'?=',$ text,$ headers,'-fno-reply@domain.com );

有人可以告诉我为什么这个工作大部分时间,但有时我收到电子邮件,没有文字主题行显示

 =?UTF-8?B ?? = 

我使用outlook express,我已经阅读了这个 System.Net.Mail和= ?utf-8?B?XXXXX ....标题
但没有帮助。



问题不在Outlook中,因为当我登录到我从中获取POP3电子邮件的实际邮件程序时,电子邮件看起来一样。



当我右键单击Outlook并选择消息来源那么没有从信息。



例如,一个好消息应该如下所示:

主题:=?UTF-8?B?w5Z2cmlndA ==?= 
MIME版本:1.0
内容类型:text / plain; charset = UTF-8
从:John Doe

但是,有问题的人看起来像这样:

主题:=?UTF-8?B ?? = 
MIME版本:1.0
内容类型:text / plain; charset = UTF-8
从:

好像信息在某处丢失了。



你也应该知道我有一个VPS,我自己管理。
我使用postfix作为一个电子邮件服务器,如果这与它有任何关系。
但是再一次,为什么它有时工作?



另外我注意到的一点是,有时特殊字符不能正确显示(由Outlook和例如,瑞典语中的Björkman名字显示为Björkman,但是再次,只是有时候。



我希望有人知道这个问题,因为很难跟踪我至少。



如果你需要更多的输入让我知道。



谢谢

解决方案

当查看PHP mail()时,我看到另外一行:你不应该使用 \r\\\
作为行结束?



Björkman示例看起来非常像您的邮件不被识别为UTF-8编码。


I have a website, and in the "Contact" section I have a form which users may fill in to contact me. The form is a simple form which action is a php page.

The php code:

$to = "email@domain.com";

$name=$_POST['name']; // sender name
$email=$_POST['email']; // sender email
$tel= $_POST['tel']; // sender tel
$subject=$_POST['subject']; // subject CHOSEN FROM DROPLIST, ALL TESTED
$text=$_POST['text']; // Message from sender
$text.="\n\nTel:".$tel; // Added to message to show me the telephone nr to the sender at bottom of message

$headers="MIME-Version: 1.0"."\n";
$headers.="Content-type: text/plain; charset=UTF-8"."\n";
$headers.="From: $name <$email>"."\n";

mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $text, $headers, '-fno-reply@domain.com');

Could somebody please tell me why this works most of the time, but sometimes I receive email whith no text and the subject line showing

=?UTF-8?B??=

I use outlook express, and I have read this System.Net.Mail and =?utf-8?B?XXXXX.... Headers but it didn't help.

The problem is not in Outlook, because when I log in to the actual mailprogram where I fetch the POP3 emails from, the email looks the same.

When I right click in Outlook and chose "message source" then there is no "From" information.

Ex, a good message should look like this:

Subject: =?UTF-8?B?w5Z2cmlndA==?=
MIME-Version: 1.0
Content-type: text/plain; charset=UTF-8
From: John Doe 

However, the ones with problem looks like this:

Subject: =?UTF-8?B??=
MIME-Version: 1.0
Content-type: text/plain; charset=UTF-8
From:  

As if the information has been lost somewhere.

You should know also that I have a VPS, which I manage myself. I use postfix as an emailserver, if thats got anything to do with it. But then again, why does it work sometimes?

Also another thing that I have noticed is that sometimes special characters are not shown correctly (by both Outlook and the webmail).

For instance, the name "Björkman" in swedish is shown like Björkman, but again, only sometimes.

I hope anybody knows something about this problem, because it is very hard to track down for me atleast.

If you need more input let me know.

Thanks

解决方案

When looking at PHP mail(), I see another line breaking: shouldn't you use \r\n as line endings?

And that Björkman example looks very much like your mail is not recognized as UTF-8 encoded.

这篇关于=?UTF-8?B ?? =在通过php邮件问题发送的电子邮件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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