outlook不识别base64编码的附件(gmail确实)

时间:2016-12-02 14:50:47

标签: php base64 email-attachments

我正在学习如何将base64编码图像附加到使用AWS生成并使用AWS发送的电子邮件中。发送到我的Gmail地址似乎工作得很好,但发送到Outlook 2003的帐户,有一个附件,但它的142B。 在我看来,这可能是一个前景设置问题,或者gmail宽恕了我的错误,前景不是。

    $pName = "frank";
    $pSubject = "test email";
    $pToEmail ="me@gmail.com"; // alternate = "me@work.com" picked up on outlook 2003

    $attachedFile = '/Code/test.jpg';
    $check = getimagesize($attachedFile);

    $message = "To: $pName <". $pToEmail .">\n";
    $message .= "From: Frank <franki@franki.co.uk>\n";
    $message .= "Subject: ".$pSubject."\n";
    $message .= "MIME-Version: 1.0\n";
    $message .= 'Content-Type: multipart/mixed; boundary="frankis_image_boundary_02122016"';
    $message .= "\n\n";
    $message .= "--frankis_image_boundary_02122016\n";
    $message .= 'Content-Type: text/plain; charset="utf-8"';
    $message .= "\n";
    $message .= "Content-Transfer-Encoding: 7bit\n";
    $message .= 'Content-Disposition: inline';
    $message .= "\n\n";
    $message .= "Dear new tester,\n\n";
    $message .= "Attached is the file you requested.\n";
    $message .= "\n\n";
    $message .= "--frankis_image_boundary_02122016\n";
    $message .= "Content-ID: <test.jpg@domain.com>\n";

    $message .= 'Content-Type: '.$check['mime'].'; name="test.jpg"';
    $message .= "\n";
    $message .= "Content-Transfer-Encoding: base64\n";
    $message .= 'Content-Disposition: attachment; filename="test.jpg"';
    $message .= "\n";
    $message .= base64_encode(file_get_contents($attachedFile));
    $message .= "\n";
    $message .= "--frankis_image_boundary_02122016--\n";


    $sendMsg['RawMessage']['Data']         = (string)base64_encode($message);
    $sendMsg['RawMessage']['Source']       = "franki@franki.co.uk";
    $sendMsg['RawMessage']['Destinations'] = array($pToEmail);


    //$client appropriately set up here

    $result = $client->sendRawEmail($sendMsg);

这里的许多搜索都讨论了在Outlook中嵌入图像的问题,我只是希望它作为附件发送。任何解决方案或建议表示赞赏。

0 个答案:

没有答案