ecard mail function won't display image

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
greygrey
Forum Newbie
Posts: 3
Joined: Thu Dec 16, 2010 6:39 am

ecard mail function won't display image

Post by greygrey »

:|

Hi. I'm a self taught developer, learned php on an as-needed basis so don't have knowledge of how servers communicate. My ecard code seems to work well except the card image doesn't display in the recipient's email. A suggestion from another forum was to save the image file to the server, then use the path in the mail function. My image files are already on my host's server, so I'm not sure why I'd need to do that (and couldn't figure out how if I did). Here is part of the program. (I used sessions to load values from previous pages, including the image file name. var_dump showed the value to be correct in each case, e.g. fileName.jpg. I later added the specific path to the host server, but it still didn't work).

$to = 'To: ' . $_SESSION['rEmail'];
$subject = $_SESSION['sFirstName'] . ' ' . $_SESSION['sLastName'] . ' has sent you a Kieferart eCard!';
$message ="<html><head><title>Kieferart Ecards</title>\n
<style type='text/css'>\n
#ecardImage {position:absolute; top:175; left:325}\n
#ecardSalutation {position:absolute; top:360; left:330; font-family:Arial; text-align:left; color:black; font-size:9pt; font-weight:normal}\n
#ecardMessage {position:absolute; top:370; left:330; font-family:Arial; text-align:left; color:black; width:600; font-size:9pt; font-weight:normal}\n
#ecardClosing {position:absolute; top:670; left:315; font-family:Arial; text-align:left; color:black; font-size:9pt; font-weight:normal}\n
</style>
</head>
<body bgcolor='#000000' link='#000000' vlink='#ff00ff'>\n
<div id='ecardImage'>\n
<img src='" . $_SESSION[imageName] . "' width = '625' height='550' alt='" . $altName . "'>\n
</div>
<div id='ecardSalutation' align='left'>" . $_SESSION['salutation'] . "</div>\n
<div id='ecardMessage' align='left'>" .
$_SESSION['comments'] . "\n
<div id='ecardClosing' align='left'>" . $_SESSION['closing'] . "</div>\n";
$message = wordwrap($message, 70);
$headers = "From: " . $_SESSION['sEmail'] . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);
?>

I'd really appreciate some patient person to walk me through the error of my ways.

Thank you,
greygrey
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: ecard mail function won't display image

Post by califdon »

Right off the bat I see that you are missing single quotes around the imagename index of $_SESSION. That may be your problem. The way you can debug this is to look at the "source" code when the page is viewed in your browser. See if there's anything in your <img src=........> tag.

For future reference, please use the "PHP Code" button when posting code in the forum. It formats your code to make it much easier for us to read. Thank you.
Post Reply