A1Nasir A1Nasir - 1 year ago 107
PHP Question

Add Picture In Email Body

i am not too good with PHP and programming but still i am trying to learn it in every possible way. I need help from experts. My code to send email is as below. i am able to send email, but the problem is, picture is not displaying in email body and it's showing a cross sign. any possible idea and suggestion is appreciated.


function send_email($from, $to, $subject, $message){
$headers = "From: ".$from."\r\n";

$headers .= "Return-Path: ".$from."\r\n";
$headers .= "CC: abc@gmail.com\r\n , xyz@gmail.com\r\n";
$headers .= "BCC: \r\n";
//set content type to HTML
$headers .= "Content-type: text/html\r\n";

if ( mail($to,$subject,$message,$headers) )



//Function ends here
$message.="<html><body background='images/bg11.jpg'>";
$message.="<p style=' color: #006789;'>Dear Team,</p> ";
$message.= "<p style=' color: #006789;'>You have received a feedback from $name & below are the details!!! </p>";
$message.= "<img src=images/c22.jpg>";
$message.="</body></html> ";

Answer Source

You are using a relative path:

<img src=images/c22.jpg>

When you open your mail, that path will mean nothing in a mail client and it is highly unlikely to exist on a webmail client. And if it does, it is not your image...

If you have that image stored on a web-server, you should use the absolute path to that image:

<img src="http://www.your-server.com/images/c22.jpg">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download