Jump to content

Recommended Posts



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.\n
http://www.santorographics.com/tutticuti/icecreamgame\n
".$_POST['yourMessage']."\n
Have 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]
------------------------
Link to comment
https://forums.phpfreaks.com/topic/33918-email-not-displaying-html/
Share on other sites

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.
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.

Regards
Huggie
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]


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.php

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/
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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.