1

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.

Marcello Impastato
  • 2,263
  • 5
  • 30
  • 52

1 Answers1

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