空白多部分电子邮件

发布于 2024-12-02 02:16:19 字数 1221 浏览 0 评论 0原文

我正在使用 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--

I'm using PHP to send out a multipart/mixed message (plain text, html and attachments). However, whilst it works for most accounts, Yahoo, GMail and Sky seem to show blank emails. Where as everything else seems to display the email. ANY HELP WOULD BE GREATLY APPRECIATED!

My headers are

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

And the content is;

--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--

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

黯淡〆 2024-12-09 02:16:19

这可能是粘贴造成的伪影,但请尝试删除每个边界末尾的空白。 (突出显示文本,您会注意到边界有一个额外的空格,但闭合边界没有)

It may be an artifact from pasting, but try removing the blank space at the end of each boundary. (Highlight the text and you'll notice the boundaries have an extra space, but the closing boundaries-- do not)

抱着落日 2024-12-09 02:16:19

请验证您的代码是否如下所示,因为以下代码对我来说工作正常。

$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."--";

Please verify whether your code is look like the following because the following code is working fine for me.

$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."--";
忆伤 2024-12-09 02:16:19

不要构建您自己的 MIME 消息。使用 SwiftmailerPHPMailer 为您做这件事。

Don't build your own MIME messages. use Swiftmailer or PHPMailer to do it for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文