0

If I use this code it shows me the image. But I want to send this in my email body. But inside the email body when I write this code it shows only the image tag with the binary code.

How can I send this image as my email body image with the binary code?

Is there any way to send this?

I repeat I have only the binary code of Image.

I am sending mail with phpmailer.

 <img src="data:image/png; base64, iVBORw0KGgoAAAANSUhEUgAAANIAAANBCAYAAAC ..." />

1 Answers1

0

data URLs should work fine in PHPMailer, but your formatting isn't quite right - there should be no spaces in there, so try this:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANIAAANBCAYAAAC ..." />

Failing that, you can attach binary data directly as an attachment using addStringAttachment, like this:

$mail->addStringAttachment($imagedata, 'image.jpg');

PHPMailer will set the encoding and MIME type for you. Note that this expects raw binary data, not base64-encoded.

Synchro
  • 35,538
  • 15
  • 81
  • 104