blob images in mail()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Catz
Forum Newbie
Posts: 8
Joined: Wed Dec 15, 2004 4:08 pm

blob images in mail()

Post by Catz »

Hi

I have a script that successfully sends a message:

(The Basic Script):

Code: Select all

$from = "me@myemail.co.za";
$subject = "Test E-Mail";

$headers = "MIME-Version: 1.0\r\n"; 
$headers = "From: My Email<$from>\n"; 
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 

$message = "This is an html message with images";
$message .= "<img src='http://www.mywebsite.com/images/logo.jpg' width='60' height='60'>";
$message .= "<img src=''http://www.mywebsite.com/view.php?ID=$ID";

if (mail($email,$subject,$message,$headers)) { 
echo "Message has been sent";
}
else {
   echo "Message was not sent <p>";
   exit;
}
The email sends fine, the logo displays fine, but the blob image comes up blank. If I copy the url directly into my browser the blob image displays with no problem. Any ideas?

Thanks!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

yar html for the "blob" has scurvy, yar.

Code: Select all

$from = "me@myemail.co.za";
$subject = 'Test E-Mail';

$headers = "MIME-Version: 1.0\r\n";
$headers = "From: My Email<$from>\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

$message = 'This is an html message with images';
$message .= '<img src="http://www.mywebsite.com/images/logo.jpg" width="60" height="60" />';
$message .= '<img src="http://www.mywebsite.com/view.php?ID='.$ID.'" />';

if (mail($email,$subject,$message,$headers)) {
echo "Message has been sent";
}
else {
   echo 'Message was not sent <p>';
   exit;
}
try that, matey.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Code: Select all

$message .= "<img src=''http://www.mywebsite.com/view.php?ID=$ID";
Methinks the second is not quite valid html...?

Corrected:

Code: Select all

$message .= "<img src='http://www.mywebsite.com/view.php?ID=$ID'>";
Catz
Forum Newbie
Posts: 8
Joined: Wed Dec 15, 2004 4:08 pm

Post by Catz »

I've also tried:

Code: Select all

$message .= "<img src='http://www.mywebsite.com/view.php?ID=" . $ID . "'>";
without success...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

some mail clients will block image links that look like trackers, yar... yours does indeed look like a tracking image... yar..
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

are you using a form? if so is the method set to POST or GET
$_POST['ID'] or $_GET['ID']

if its coming from the url use $_GET['ID']
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Have viewed text prior to sending? i.e. the html received by client?

Maybe $ID not being set...or its being blocked...or you need a superglobal...or...
Post Reply