电子邮件在某些客户端上没有内容

时间:2017-03-31 10:19:08

标签: php email

看来我的电子邮件只能在GMail上正确呈现。我查看了最后的标题,我没有看到任何破坏:

From: VENE - noreply <krabuz22@gmail.com>
X-Google-Original-From: VENE - noreply <steve.steve@company.com>
Date: Fri, 31 Mar 2017 09:59:00 +0200
To: steve2@gmail.com
Subject: [VENE-LOCAL] Please verify your email
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary=_xf76c2f45c241585f23339503d742de8112b91cfbx

--_xf76c2f45c241585f23339503d742de8112b91cfbx
Content-type: text/plain;charset=utf-8

[...here goes the plain text...]

--_xf76c2f45c241585f23339503d742de8112b91cfbx
Content-type: text/html;charset=utf-8

<html>
<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
    <style type="text/css">
        [...css...]
    </style>
</head>
<body>
    [...here goes the html...]
</body>
</html>

--_xf76c2f45c241585f23339503d742de8112b91cfbx
Content-Type: application/pdf; name="file.pdf";
Content-Transfer-Encoding: base64;
Content-Disposition: attachment; filename="file.pdf";


--_xf76c2f45c241585f23339503d742de8112b91cfbx--

我尝试删除附件,图片,更改内容类型,但结果保持不变:

iPad(由inboxinspector.com预览): iPad

这是我合并电子邮件的方式:

protected function _sendEmail($bodyPlain, $bodyHtml, $subject, $recipients, $attachmentPath = null, $saveEmail = true) {
        if (!$bodyPlain && !$bodyHtml) {
            return false;
        }

        $boundary = '_x'.sha1(time()).'x';
        $subject = '['.$this->_config->APP_NAME.'] '.$subject;

        $headers = "MIME-Version: 1.0\n";
        $headers .= 'From: '.$this->_config->EMAIL['name-noreply'].' <'.$this->_config->EMAIL['address-noreply'].'>'."\n";
        $headers .= "Content-Type: multipart/alternative; boundary=\"".$boundary."\"\n";

        $message = "";

        // Plain text body
        if (isset($bodyPlain)) {
            $message .= "\n\n--".$boundary."\n";
            $message .= "Content-Type: text/plain; charset=utf-8\n";
            $message .= $bodyPlain;
        }

        // Html body
        if (isset($bodyHtml)) {
            $message .= "\n\n--".$boundary."\n";
            $message .= "Content-Type: text/html; charset=utf-8\n";
            $message .= $bodyHtml;
        }

        if (isset($attachmentPath)) {
            $message .= $this->_addAttachment($attachmentPath, $boundary);
        }

        $message .= "\n\n--".$boundary."--";

        foreach ($recipients as $address) {
            mail($address, $subject, $message, $headers);
        }
    }

0 个答案:

没有答案