Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed images in HTML email on the mail server?

Tags:

html

email

How does one embedd an image in HTML so that the image is delivered with the html file content and does not need a separate trip to the server to retrieve the image? We need this to embed company logo's into signatures before they leave the mail server. We don't want to use a client side solution like thunderbird's or outlook's functionality to add signatures.

thanks

like image 429
mxc Avatar asked Feb 08 '09 06:02

mxc


People also ask

How do I put an image in the body of my email?

Insert a picture into the body of an email messageSelect Insert > Pictures. Browse your computer or online file locations for the picture you want to insert. Select the picture, then select Insert.


2 Answers

What you need to do is encode the file to Base64, and include it like this:

<img src="data:image/gif;base64,R0lGODlhUAA..(the rest of your base64 encoded file)..">

http://www.sweeting.org/mark/blog/2005/07/12/base64-encoded-images-embedded-in-html

http://dean.edwards.name/weblog/2005/06/base64-ie/

like image 194
nickf Avatar answered Sep 30 '22 20:09

nickf


The standard solution for that is to add the image as an attachment. Every attachment has a ContentID, so you can embed the image using: <img src="cid:ContentID" />.
This will embed the image in the email, not in the html.

like image 26
Kobi Avatar answered Sep 30 '22 20:09

Kobi