How can I embed an image into an email acceptable to Outlook

Viewed 525

I've got some working php code to embed an image into email, as follows:

<?php

// Initialise
$mailTo =  "john@auser.com";    
$mailSubject = "Image Test";

// (Construct HTML header
$mailHead = implode("\r\n", [
  "MIME-Version: 1.0",
  "Content-type: text/html; charset=utf-8",
  "From: noreply@asite.com"
]);

// Build email body - the image is directly embedded using Base64 Encode
$path = 'test.jpg';
$img = file_get_contents($path);
$imgdata = base64_encode($img);
$mailBody = "<p>Here is an image.</p>";
$mailBody = $mailBody . "<img src='data:image/jpg;base64," . $imgdata . "'/><br>";

// Send email
echo $mailBody;
echo mail($mailTo, $mailSubject, $mailBody, $mailHead)
  ? "OK" : "ERROR" ;

?>

This code displays the whole email, including the image, when you run it as a confirmation. I can receive this OK on my mobile using the default Email app, but in Outlook it doesn't come through. I get the small square to show an image is present, but right-clicking and selecting Download pictures shows nothing.

Can anyone suggest a fix or recommend a different method that will work on Outlook? Many thanks

1 Answers
Related