Looking for html-email format, how i can include a jpeg-image (logo) in a email without call absolute address from website and without put it as attachment in it? Thanks.
Asked
Active
Viewed 225 times
1
-
You can use a data: url as the src of the image: [stackoverflow](https://stackoverflow.com/questions/1207190/embedding-base64-images) – Adder Aug 09 '17 at 14:36
-
Like something as copy/paste jpeg-file inside tag
? – Marcello Impastato Aug 09 '17 at 14:38
-
1Like you have to transform the image data to base64 encoding and paste this as part of the url in img tag. – Adder Aug 09 '17 at 14:41
-
ok thanks! i will try. – Marcello Impastato Aug 09 '17 at 14:43
-
You can use img src method – perumal N Aug 09 '17 at 14:55
1 Answers
1
Basically you need to read the contents of the image and transfer them to data uri which you can "inline" into the html like this:
$image_data=file_get_contents("some_image.jpg");
$encoded=base64_encode($image_data);
echo "<img src='data:image/jpeg;base64,{$encoded}'>";
Of course you will not echo the image tag, you just ineed to put it into the email with your preferred mailer client.

Kyborek
- 1,519
- 11
- 20
-
Using base64 may work in some email clients, but it is not supported by some major email clients: https://www.caniemail.com/features/image-base64/ – LaVomit Jul 05 '22 at 07:25