zircon Posted January 12, 2007 Share Posted January 12, 2007 I have a email problem with the following code. This was perfectly working fine and sending a HTML email earlier. Recently we have moved to a new server and the email does not display the HTML, it just displays as a text message. Can some one advice me in this regard?Thanks in advance fro your help!--------------------------------------------[code]<? include("config.php")?><?php$sql = "insert into tbluser (yourName,yourEmail,yourFName,friendsEmail,yourMessage,yourScore,post_date) values ('".$_POST['yourName']."','".$_POST['yourEmail']."','".$_POST['yourFName']."','".$_POST['friendsEmail']."','".$_POST['yourMessage']."','".$_POST['yourScore']."','".date('y-m-d',strtotime("now()"))."')";//die($sql);mysql_query($sql) or die("Error is ".mysql_error());$id = mysql_insert_id();if (isset($_POST['yourEmail'])){$HTML = "Dear ".$_POST['yourFName'].",\n\n";$HTML .= "Check out this cheeky little outfit designed by me exclusively for tutticuti™!<br><br />Click on the following link to view the outfit.<br><br><a href='http://www.domainname.com/folder/game/viewDesign1.php?id=".$id."' target='_blank'>http://www.domainname.com/folder/game/viewDesign1.php?id=".$id."</a><br><br>".$_POST['yourMessage']."<br><br>Thanks,<br>".$_POST['yourName'];$HTML .= "I have just found a fantastic new titti cuti ice cream game at Santoro website and I have scored ".$_POST['yourScore']." points. If you want to play the game and beat my score, please go the following web site.\nhttp://www.santorographics.com/tutticuti/icecreamgame\n".$_POST['yourMessage']."\nHave fun. Cheers!\n\n".$_POST['yourName']; $to = $_POST['friendsEmail']; $sub = "Your friend (".$_POST['yourName'].") sent you an email."; $headers = "MIME-Version: 1.0\r\n"; $headers = "Content-type: text/html; charset=iso-8859-1\r\n"; $headers = "Return-Path: bounces@domain.com\r\n"; $headers = "bcc: webmaster@domain.com\r\n"; $headers = "From: ".trim($_POST['yourName'])."<".trim($_POST['yourEmail']).">\r\n"; mail($to, $sub, $HTML, $headers); }?>[/code]------------------------ Quote Link to comment https://forums.phpfreaks.com/topic/33918-email-not-displaying-html/ Share on other sites More sharing options...
Jessica Posted January 12, 2007 Share Posted January 12, 2007 1. <? include("config.php")?>missing ;2. Each time $headers is overwritten. Try .= instead of = Quote Link to comment https://forums.phpfreaks.com/topic/33918-email-not-displaying-html/#findComment-159239 Share on other sites More sharing options...
zircon Posted January 16, 2007 Author Share Posted January 16, 2007 Many thanks Jesirose..I have changed <? include("config.php") ?> to <? include("config.php"); ?> and changed $headers = to $headers .=Then it worked perfectly in Yahoo and Hotmail and in other accounts.Now the new problem is 'gmail' still shows as text mail and showing sender as (unknown sender). I have already mentioned 'Return-Path' in the header.$headers = "Return-Path: [email]bounces@domain.com[/email]\r\n";Any advice in tis regard?Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/33918-email-not-displaying-html/#findComment-161872 Share on other sites More sharing options...
zircon Posted January 16, 2007 Author Share Posted January 16, 2007 anybody got a clue? Quote Link to comment https://forums.phpfreaks.com/topic/33918-email-not-displaying-html/#findComment-161981 Share on other sites More sharing options...
HuggieBear Posted January 16, 2007 Share Posted January 16, 2007 If it shows OK in Hotmail and Yahoo then it's not an email issue, it's a client issue. Is there a setting in Gmail to turn off HTML, does it normally display HTML messages ok?RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/33918-email-not-displaying-html/#findComment-161987 Share on other sites More sharing options...
zircon Posted January 16, 2007 Author Share Posted January 16, 2007 There are no such settings to turn off HTML in gmail. I have sent the same mail to gmail and Yahoo. Yahoo displayed ferfect and gmail did not. I have forwarded the same Yahoo mail to gamil and displayed perfectly. Do you have any advice? Quote Link to comment https://forums.phpfreaks.com/topic/33918-email-not-displaying-html/#findComment-162024 Share on other sites More sharing options...
HuggieBear Posted January 16, 2007 Share Posted January 16, 2007 OK, in that case maybe it is the email, maybe Gmail doesn't like the headers.I googled for [i]gmail +php +mail +headers[/i] and found some very interesting results. Especially the first listing!If I had a Gmail account I'd test some, but I'm afraid I don't. Have a search and I'm sure it'll help out.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/33918-email-not-displaying-html/#findComment-162030 Share on other sites More sharing options...
ki Posted January 16, 2007 Share Posted January 16, 2007 Some email service providers such as gmail decode html unlike yahoo and others. So try sending \n for <br> Quote Link to comment https://forums.phpfreaks.com/topic/33918-email-not-displaying-html/#findComment-162032 Share on other sites More sharing options...
Daniel0 Posted January 16, 2007 Share Posted January 16, 2007 Try [tt]Content-Transfer-Encoding: quoted-printable[/tt] as well. Quote Link to comment https://forums.phpfreaks.com/topic/33918-email-not-displaying-html/#findComment-162038 Share on other sites More sharing options...
zircon Posted January 16, 2007 Author Share Posted January 16, 2007 I have tried using Content-Transfer-Encoding: Quoted-PrintableBut did not work.Why Gmail is showing senders name as (unknown user)? Any advice? Quote Link to comment https://forums.phpfreaks.com/topic/33918-email-not-displaying-html/#findComment-162051 Share on other sites More sharing options...
ki Posted January 16, 2007 Share Posted January 16, 2007 try removing the \r\n Quote Link to comment https://forums.phpfreaks.com/topic/33918-email-not-displaying-html/#findComment-162218 Share on other sites More sharing options...
zircon Posted January 17, 2007 Author Share Posted January 17, 2007 [code]try removing the \r\n[/code]I tried, but it did not work. Any clue? Quote Link to comment https://forums.phpfreaks.com/topic/33918-email-not-displaying-html/#findComment-162692 Share on other sites More sharing options...
zircon Posted January 17, 2007 Author Share Posted January 17, 2007 Hi Guys,Thanks very much in deed for the help.Now the problem has benn fixed forever.The same script was working fine when it was run on our old server since couple of years. When we have migrated to a new server last month, all these strange problems started. With all the research these days, I have found the PHP core info shows "safe_mode=on" is the major point. By restricting the PHP to safe mode all more than 35 functions wil misbehave as stated on the php.net site.Please follow the link to know more about it.Also, we had a problem with gmail while compared with different emails like Yahoo, hotmail..etc.Follow this link to know more on Gmail problem.http://www.bigroom.co.uk/blog/php-mail-and-gmail/and finally, the following code worked when I removed \r from \r\n [code]$to = $_POST['friendsEmail']; $sub = "".$_POST['yourName']."'s cheeky little outfit design for tutticuti™"; $headers .= "MIME-Version: 1.0'\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "Content-Transfer-Encoding: Quoted-Printable\n"; $headers .= "Return-Path: newsletters@santorographics.com\n"; $headers .= "bcc: dressupmails@yahoo.com\n"; $headers .= "From: ".trim($_POST['yourName'])."<".trim($_POST['yourEmail']).">\n"; //$headers .= "Reply-To: "($_POST['yourEmail'])"\n"; mail($to, $sub, $HTML, $headers);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/33918-email-not-displaying-html/#findComment-162711 Share on other sites More sharing options...
zircon Posted January 17, 2007 Author Share Posted January 17, 2007 Hi Guys,Thanks very much in deed for the help. Now the problem has been fixed forever. Juat a quick brief about the problem.The same script mentioned in the top was working fine when it was run on our old server since couple of years. When we have migrated to a new server last month, all these strange problems started. With all the research these days, I have found the PHP core info shows "safe_mode=on" is the major point. By restricting the PHP to safe mode all more than 35 functions had few limitations as stated on the php.net site. So mail(); had some limitations with some mail clients.Please follow the link to know more about it.http://nl3.php.net/manual/en/features.safe-mode.functions.phpAlso, we had a problem with gmail while compared with different emails like Yahoo, hotmail..etc. Follow this link to know more on Gmail problem.http://www.bigroom.co.uk/blog/php-mail-and-gmail/http://www.ablogapart.org/2005/12/07/php-mail-and-gmail-a-warning-on-headers/and finally, the following code worked when I removed \r from \r\n [code] $to = $_POST['friendsEmail']; $sub = "Subject line goes here"; $headers .= "MIME-Version: 1.0'\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "Return-Path: xyzxyz@domainname.com\n"; $headers .= "From: ".trim($_POST['yourName'])."<".trim($_POST['yourEmail']).">\n"; mail($to, $sub, $HTML, $headers);[/code]Thanks,Jag Quote Link to comment https://forums.phpfreaks.com/topic/33918-email-not-displaying-html/#findComment-162713 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.