Klauwaart Posted October 20, 2007 Share Posted October 20, 2007 Hello, I have set up a PHP program to send emails to people who subscribe/unsubscribe to a newsletter. Everything works fine except for one thing: I want to include a logo (a .jpg) to which I link via my site. The code is this: <HTML> <HEAD> <TITLE>Vlaanderen-Flanders</TITLE> </HEAD> <BODY> <?php // Always try to connect and select the DB before anything else $con = mysql_connect("localhost","mrdee_mrdee","musical") or die("Couldnt Connect to DB - ".mysql_error()); mysql_select_db("mrdee_reloader", $con) or die("Couldnt Select a DB - ".mysql_error()); // Set post var $Epost = trim(addslashes(strip_tags($_POST['Epost']))); // Look for it in DB $query = "SELECT Epost FROM newsletter WHERE Epost='".$Epost."'"; $result = mysql_query($query); // If more than 0 rows are found, then we've found a match.. so check it if (mysql_num_rows($result) > 0 ) { echo 'Email does not exist.'; } else { mysql_query("DELETE FROM newsletter WHERE Epost='$Epost'") or die(mysql_error()); } mysql_close($con); $email_address_to = "$Epost"; $foto = "http://www.vlaanderen-flanders.org.uk/Pics/Vlaamse Leeuw.jpg"; $stek = "http://www.vlaanderen-flanders.org.uk"; $subject = "Bedankt"; $message_contents = "Hello,\n you are now taken off our newsletter list.\n Should you change your mind, you are always welcome to subscribe again.\n Flemish regards,\n The webmaster.\n $stek\n sfoto"; $header = "From: webbie@vlaanderen-flanders.org.uk\r\n"; $header .= "Reply-To: webbie@vlaanderen-flanders.org.uk\r\n"; $header .= "webbie@vlaanderen-flanders.org.uk\r\n"; mail($email_address_to,$subject,$message_contents,$header); ?> <div align="center"><img src="Pics/Vlaamse Leeuw.jpg" width="114" height="127" alt="" border="0" align=""></div> <p align="center"><b>Thank you, you have now been taken off the list.</b></p><br> <p align="center"><a href="index.htm"><img src="Pics/begin.gif" width="95" height="30" border="0"></a></p> </BODY> </HTML> The only problem is: at the bottom, the email prints "$foto" rather than the expected actual picture. It does print the URL ($stek variable) correctly however. How can i solve this problem, please? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/74071-solved-logo-does-not-seem-to-work/ Share on other sites More sharing options...
ignace Posted October 20, 2007 Share Posted October 20, 2007 you wrote sfoto instead of $foto uitgeweken vlaming, waar woon je dan nu? moved away from the flanders, where do you live then now? Quote Link to comment https://forums.phpfreaks.com/topic/74071-solved-logo-does-not-seem-to-work/#findComment-373927 Share on other sites More sharing options...
Klauwaart Posted October 20, 2007 Author Share Posted October 20, 2007 Of course, how stupid of me. I checked, double checked and checked again, but could not find it. Sorry if I wasted peoples' time. Thanks, Klauwaart. Quote Link to comment https://forums.phpfreaks.com/topic/74071-solved-logo-does-not-seem-to-work/#findComment-373938 Share on other sites More sharing options...
Klauwaart Posted October 20, 2007 Author Share Posted October 20, 2007 There is still a hiccup now. In the email that arrives, instead of the picture, it shows part of the URL, the rest is printed in orinary black. (Everything after 'Vlaamse' is printed in black, everything before that as a URL link). Quote Link to comment https://forums.phpfreaks.com/topic/74071-solved-logo-does-not-seem-to-work/#findComment-373942 Share on other sites More sharing options...
steve448 Posted October 20, 2007 Share Posted October 20, 2007 If you want to display an image in an email then you will need to send it as html. Which means you have to include the content-type header so the receivers mail client knows that it contains html. Something like: <?php $header .= "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\r\n" . "Content-Transfer-Encoding: 7bit\r\n"; ?> And then use the html image tag Quote Link to comment https://forums.phpfreaks.com/topic/74071-solved-logo-does-not-seem-to-work/#findComment-373985 Share on other sites More sharing options...
Klauwaart Posted October 20, 2007 Author Share Posted October 20, 2007 Thanks, I entered that, but it still sends in the same way. Quote Link to comment https://forums.phpfreaks.com/topic/74071-solved-logo-does-not-seem-to-work/#findComment-373997 Share on other sites More sharing options...
steve448 Posted October 20, 2007 Share Posted October 20, 2007 The break in the link to your image is probably to do with the space in the filename, best to urlencode it, or not use spaces in your file names. Sending html emails can be a right pain, mainly because you are at the mercy of whichever email company happens to be displaying the message, some allow some things, some don't. Are you including your logo in a html tag? I.e. <img src="your_logo_file" alt="put_something_here" /> Is it just displaying the raw html or nothing? Are you sure your email account will display html? It is usually better to send a multipart message, which contains both a html and a plain text version, since your users will be using all different mail clients. Quote Link to comment https://forums.phpfreaks.com/topic/74071-solved-logo-does-not-seem-to-work/#findComment-374005 Share on other sites More sharing options...
thebadbad Posted October 20, 2007 Share Posted October 20, 2007 A rule of thumb: When dealing with files online, ALWAYS stick to lowercase filenames, without any strange characters like the space. I only use letters from a-z, "_", "-" and/or periods in my filenames. Quote Link to comment https://forums.phpfreaks.com/topic/74071-solved-logo-does-not-seem-to-work/#findComment-374011 Share on other sites More sharing options...
Klauwaart Posted October 20, 2007 Author Share Posted October 20, 2007 OK, thanks. I think I have found the best solution: I have removed the picture from the code altogether. When I entered it in HTML tags I got an error. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/74071-solved-logo-does-not-seem-to-work/#findComment-374015 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 Don't forget to mark as solved if your problem is solved. Quote Link to comment https://forums.phpfreaks.com/topic/74071-solved-logo-does-not-seem-to-work/#findComment-374026 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.