Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.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
Php 空白多部分电子邮件_Php_Email_Yahoo_Multipart - Fatal编程技术网

Php 空白多部分电子邮件

Php 空白多部分电子邮件,php,email,yahoo,multipart,Php,Email,Yahoo,Multipart,我使用PHP发送多部分/混合消息(纯文本、html和附件)。然而,虽然它适用于大多数账户,但雅虎、GMail和Sky似乎都会显示空白电子邮件。在那里,其他一切似乎都显示了电子邮件。任何帮助都将不胜感激 我的标题是 $headers .= "Content-Type: multipart/mixed; boundary=\"mixed-" . $random_hash . "-mixed\"\n"; $headers .= "MIME-Version: 1.0\n"; 内容是, --mixed

我使用PHP发送多部分/混合消息(纯文本、html和附件)。然而,虽然它适用于大多数账户,但雅虎、GMail和Sky似乎都会显示空白电子邮件。在那里,其他一切似乎都显示了电子邮件。任何帮助都将不胜感激

我的标题是

$headers .= "Content-Type: multipart/mixed; boundary=\"mixed-" . $random_hash . "-mixed\"\n";
$headers .= "MIME-Version: 1.0\n"; 
内容是,

--mixed-7df05b31-mixed  

Content-Type: multipart/alternative; boundary="alt-7df05b31-alt"  

--alt-7df05b31-alt 

Content-Type: text/plain; charset=utf-8 

            Hello how are you? I am just checking the mailing function.

            Hopefully this will work!

            Cheers.

--alt-7df05b31-alt 

Content-Type: text/html; charset=utf-8 

<div style="font-family:Arial, Helvetica, sans-serif; font-size: 10pt;">

<div> 


            Hello how are you? I am just <b>checking</b> the mailing function.<br><br>


            Hopefully this will work!<br><br>


            Cheers.</div></div>

--alt-7df05b31-alt--

--mixed-7df05b31-mixed 

Content-Type: text/plain; name="abc.txt"  
Content-Disposition: attachment; filename="abc.txt"   
Content-Transfer-Encoding: base64

SEVMTE8gSlVTVCBURVNUSU5HIC4uLiA=

--mixed-7df05b31-mixed--
--mixed-7df05b31-mixed
内容类型:多部分/备选;boundary=“alt-7df05b31-alt”
--alt-7df05b31-alt
内容类型:文本/纯文本;字符集=utf-8
你好,你好吗?我只是在检查邮件功能。
希望这能奏效!
干杯
--alt-7df05b31-alt
内容类型:text/html;字符集=utf-8
你好,你好吗?我正在检查邮件功能。

希望这能奏效

干杯 --alt-7df05b31-alt-- --混合-7df05b31-混合 内容类型:文本/纯文本;name=“abc.txt” 内容处置:附件;filename=“abc.txt” 内容传输编码:base64 七个GSLvTvUrvnusUlia= --混合-7df05b31-混合--
不要构建自己的MIME消息。使用或为您做。

< P>这可能是粘贴的工件,但是尝试删除每个边界末尾的空白。(突出显示文本,您会注意到边界有一个额外的空间,但闭合边界--不要)

请验证您的代码是否与下面的代码类似,因为下面的代码对我来说工作正常

$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
$headers .= "This is a multi-part message in MIME format.\r\n";
$headers .= "--".$uid."\r\n";
$headers .= "Content-type:text/html; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$headers .= $msg."\r\n\r\n";    
$headers .= "--".$uid."\r\n";
$headers .= "Content-Type:application/html; name=\"".$filename."\" \r\n"; // use different content types here
$headers .= "Content-Transfer-Encoding: base64\r\n";
$headers .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
$headers .= $content."\r\n\r\n";
$headers .= "--".$uid."--";

因为你显然做错了什么。如果你的电子邮件构造正确,它将毫无问题地出现在gmail/yahoo中-我还没有看到phpMail在我所有的项目中导致错误的消息,不管它在哪里被读取。尽管学习原始操作有一定的价值。我想知道你上面的代码有什么问题?我还发现RMail是一个功能强大且易于使用的多部分电子邮件库。“不要这样做”很少是编码的有效答案。几乎总会有需要它的情况(例如,在本例中,如果您由于某种原因无法合并外部库)。一个更合适的答案是,“我建议避免这样做,因为X的原因,但如果你需要,这里是如何…”