I am trying to send a HTML mail from php that contains an image.
I receive the email and all the HTML tags look good except for the <img>
tag.
The message of the email looks like this:
$message = '<img src="http://your-click.ch/wp-content/uploads/2014/11/logo1.png" alt="Your Click" width="131" height="52" border="0" />';
When I receive the mail, I see that there is an image but it is just blank. When I check the element, I see this code:
<img alt="Your Click" width="131" height="52" border="0">
As you see the whole src attribute is missing? Why?
Some email clients filter out externally linked images for security reasons. Try encoding the image and including it in the body of your message instead of externally linking it.
The image is probably being filtered by the recipient mail server, try base64_encode the image, i.e.:
$image = file_get_contents('http://your-click.ch/wp-content/uploads/2014/11/logo1.png');
$message = '<img src="data:image/png;base64,'.base64_encode($image).'" alt="Your Click" width="131" height="52" border="0" />';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With