Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当$headers达到一定长度时,php mail()不发送邮件_Php_Email_Encoding_Header_Postfix Mta - Fatal编程技术网

当$headers达到一定长度时,php mail()不发送邮件

当$headers达到一定长度时,php mail()不发送邮件,php,email,encoding,header,postfix-mta,Php,Email,Encoding,Header,Postfix Mta,我的PHPmail()总是在From标题达到一定长度时停止发送电子邮件。我在From标题中使用西里尔字母符号,因此我必须在windows-1251中对其进行编码(这是我需要支持的所有HTML邮件客户端中唯一有效的编码) 所以,我的代码: $to = 'myemail@test.com'; $subject = 'Cyrillic subject goes here'; $message = $letterbody; //letterbody gets form data and packs it

我的PHP
mail()
总是在
From
标题达到一定长度时停止发送电子邮件。我在
From
标题中使用西里尔字母符号,因此我必须在
windows-1251
中对其进行编码(这是我需要支持的所有HTML邮件客户端中唯一有效的编码)

所以,我的代码:

$to = 'myemail@test.com';
$subject = 'Cyrillic subject goes here';
$message = $letterbody; //letterbody gets form data and packs it into nice table
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Transfer-Encoding: 8bit\r\n"; 
//takes Lastname of the person registering, encodes it so all the clients can read, takes its email address
$headers .= "From: =?windows-1251?B?".base64_encode($lastname)."?= <$email>\r\n"; 
$headers .= "Content-type: text/html; charset=\"windows-1251\"\r\n";
mail($to,"=?windows-1251?B?".base64_encode($subject)."?=",$message,$headers);
邮件不发送,
$headers
如下所示:

MIME版本:1.0
内容传输编码:8位
发件人:=?windows-1251?B?dHR0dHR0?=
内容类型:text/html;charset=“windows-1251”

我不知道我还能做什么。由于未对
$lastname
进行编码,它似乎工作正常,但在某些电子邮件客户端上,例如Ubuntu 13上的Postfix,它是无法读取的


也许我需要在后缀中设置一些
$headers
限制?

WOW!这是大量的标题信息。你应该找到一个替代方案。比如不编码$lastname?如果我可以说,它似乎被过度“编码”。首先对标题进行
base64\u编码,然后在
mail(…)
函数中再次对其进行编码。在mail()中有$subject需要编码!在$headers中,对From:字段进行编码。愚蠢的西里尔语东西>>为什么不在
$to>下面声明
$email
变量(例如
$email=$\u POST['email'];
)myemail@test.com';
然后在跳过此部分的同时将其传递到标题中
?windows-1251?B?”。base64_encode($lastname)
$email = test@test.com;
$lastname = "tttttt"