I have set up a mail form to send emails from my webpage, and I would like to be able to set up images in these emails. This is the code I currently have:
$to = "test@test.com";
$subject = "Emergency details";
$body = "Passport picture: <img src='http://www.test.co.uk/files/passport_uploads/".$passport."'/>";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
When I send this email, the outputs looks like this:
Passport picture: <img src='http://www.test.co.uk/files/passport_uploads/test.jpg"/>
and actually displays the code rather than the picture. Is it possible to make this display the picture instead?
Thanks for any help
you are sending this email as plain text. You should specify that it should be interpreted as an html mail by using mail()’s fourth argument (headers).
Example can be found in the documentation.
The snippet: