How to create an email with embedded images that is compatible with the most mail clients

前端 未结 2 470
北恋
北恋 2020-11-28 06:05

We have created a system that allows embedding an image in an outgoing email.

Here is the original message our system creates. This example contains an image attachm

相关标签:
2条回答
  • 2020-11-28 06:28

    I've had success with exactly the same headers as you're using, with the following differences:

    • Embedded is not a valid value for the Content-Disposition header. attachment should be fine. inline should also be fine, though I've usually seen attachment for multipart/related embedded images.

    • The value of the Content-ID header is supposed to be in the same format as a message-id, which in turn looks very much like an email address. <083.gif@yourmailer> has a better chance of working with most mailers.

    0 讨论(0)
  • 2020-11-28 06:28

    I was having trouble loading inline images in Gmail and I found that I was mis-using the PEAR Mail_Mime library in PHP. As already noted, the Content-ID must be formatted like a message id. The PEAR Mail_Mime library will try to add a domainID to your Content-ID if one is not supplied. It will also attempt to regex replace these Content-ID's in the HTML body of the email to maintain the link. In my case, this step was failing which did end up breaking the link from the HTML tag to the MIME attachment. So it was perfectly correct for Gmail to refuse to display the image inline. It did display the image as an attachment however.

    0 讨论(0)
提交回复
热议问题