Hi,
i want to include images in email,i write the following script which unfortunatly not working,please any one help me resloved my issue

`$to = "example@gmail.com";
$subject = "new account created";
$body = "New account has been created
<img border=’0' src=’http://www.example.com/myimages/track.php?MID=1111&SID=2222' width=’1' height=’1'>
" ;

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: admin@gmail.com";

$neww=mail($to,$subject,$body,$headers);
`

Recommended Answers

All 12 Replies

Are you sure your image src points to valid image?

yes i am sure because this is php script to creat an image there

dear it give me the same result,the script not able to send image there,if you have any example please show me that

<?
$to = 'myemail@gmail.com';
$subject = 'test subject';
$message = 'this is <strong>html</strong> <img src="http://l.yimg.com/a/i/ww/met/yahoo_logo_in_061509.png" > message';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
echo '->'.mail($to, $subject, $message, $headers);
?>

This worked for me. But if you are giving image as a src then that image will be come loaded from live. So if you are using gmail, it will ask something like Images are not displayed. Display images below.

But if you want image as a content in email you need to take image data and add it message rather than giving url.

I use phpmalier class. It is very easy to use.

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
this one is not working for me. gmail is not asking for ""display images bellow"". what i have to do

$Image=basename($_FILES['file']['name']);
$Image=str_replace(' ','|',$Image);
$date=date('YmdHis');
$date=str_replace('%20',' ',$date);
$Image=$date.".jpg";
$tmppath="images/".$Image;

move_uploaded_file($_FILES['file']['tmp_name'],$tmppath);

the code given above is not working

This thread is over 2 years old. I suggest you start a new thread and clearly state what code you are using and what is not working. Be very specific and detailed.

Just a note, local files are not recognized when sending emails, you have to put the images on a server and then you will be able to reference them, hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.