What is the recommended way for sending personalized images in html emails?

Deadly 提交于 2019-12-23 18:42:42

问题


I know similar questions have already been asked but the answer is almost always the same: you need to share the image on a server and link to it from within the email.

For my purpose I cannot do that.

The image needs to be personalized for each user I send an email to (so the email will be dynamically generated for each user and will not always be the same. I cannot share the image -- since it will change but also for avoiding disclosure of users' information).

Have you ever encountered this scenario? Should I go with attachments or base64 encoding of images? Thoughts/experiences?


回答1:


The HTML body must refer to the images using the content id (cid): <img src="cid:xyz">, where xyz is the value of the attachment content id (Content-ID) MIME header.

If you are creating the message directly in the MIME format, make sure the attachment is added to the message and its Content-ID MIME header is properly set. If you are Outlook Object Model or MAPI, you must set the PR_ATTACH_CONTENT_ID property on the image.




回答2:


Since HTML5 allows base64 encoded images inline, this might be the easiest way to go. Check the following source: http://www.bigfastblog.com/embed-base64-encoded-images-inline-in-html

You should consider that not all mail clients might support HTML5 and therefore attaching the image and referencing it in your code may be the harder but better choice. Unfortunately I have no experience with that.

Edit: This tutorial looks promising, but I have not tried it: http://www.phpeveryday.com/articles/PHP-Email-Using-Embedded-Images-in-HTML-Email-P113.html



来源:https://stackoverflow.com/questions/23844569/what-is-the-recommended-way-for-sending-personalized-images-in-html-emails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!