Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Base64 image in email, does not show in google mail

I have created a base64 image to be sent via email to the customer on there mobile device It works in the email app but the gmail app shows a missing image

Is that just google mail blocking data images for security? There's no button to show images either

Code:

    $headers = "From: [email protected]\r\n";
    $headers .= "Reply-To: [email protected]\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

$imagedata = file_get_contents("http://www.barcodesinc.com/generator/image.php? code=12345&style=68&type=C128B&width=180&height=70&xres=1&font=1");
$base64 = base64_encode($imagedata);
$message ="<img src='data:image/png;base64,$base64'>";

mail($to,$subject,$message,$headers);</pre>
like image 850
likdaboo Avatar asked Sep 09 '13 20:09

likdaboo


People also ask

Why are images not displaying in Gmail app?

Always show images On your Android phone or tablet, open the Gmail app . your account. Under "Data usage," tap Images. Tap Always show.

Why is PNG not showing in Gmail?

On your computer, go to Gmail. See all settings. Scroll down to the "Images" section. Click Always display external images.

How do I embed a photo in a Gmail?

Gmail on the web: Compose a message, and then drag and drop the picture from your computer to the desired position in the email. Or, position the cursor where you want the image to appear, select Insert Photo > Inline, then choose your photo and select Insert.

Does SMTP use base64?

Base64 is also widely used for sending e-mail attachments. This is required because SMTP – in its original form – was designed to transport 7-bit ASCII characters only. This encoding causes an overhead of 33–37% (33% by the encoding itself; up to 4% more by the inserted line breaks).


1 Answers

It's google blocking images. Google striped out most inline css and other 'likely' vulnerablilities that cause harm to the end-users' system. Unfortunatly this is the case. However i still think you should never embed your images in e-mail, because you have a lot of mobile users with dataplans. Seems a bit rude.

like image 179
Benjamin de Bos Avatar answered Sep 29 '22 03:09

Benjamin de Bos