1

i am working on a project where i have to send emails with images, but the problem is the image must be sent inside message body not as attachment, i have tried a lot from my side, but no result found. Please provide me some appropriate solution to sort out this problem.

Thanks in advance...

1 Answers1

1

Create a base64 string from the image and use this as the src.

$img = file_get_contents('image.jpg');
$img_b64 = base64_encode($img);

echo "<img src='data:image/jpeg;base64," . $img_b64 . "' />";

If you use another kind of image files, you will have to use another mime type.

Jerodev
  • 32,252
  • 11
  • 87
  • 108