Reputation: 145
Hoi Everyone, I'm new in php programming. I just wanted to ask a little help from you guys about how can I attach an image file using php mail() function. I've already tried html/text and it works great and it sends to my email. but the problem is when I change the content type to image/jpg. it's not working. All I need now is a way to attach the image file in php mail() not using any php libraries. Thank you .
Upvotes: 1
Views: 3687
Reputation: 1135
<?php
$to = '[email protected]';
$subject = 'test subject';
$message = 'this is <strong>html</strong> <img src="http://www.test.com/image.test.png" > message';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);
?>
Try this. provide exact path of image which is located on server.
Upvotes: 2