By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,747 Members | 2,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,747 IT Pros & Developers. It's quick & easy.

php formatted html shows up in Yahoo mail but not gmail

P: n/a
I sent HTML formatted email, using PHP, to my Yahoo address from my
server, and it came out fine, styles and all. I sent it to my gmail
address to test it and all I see is the raw html code. But I do get
formatted email in gmail, so I know people make it work somehow. I'm
looking right at a gmail message that I copied to Dreamweaver and it's
using Strong and Red text attributes that work in gmail. But mine
don't.

What do you do different in gmail to get formatted HTML email?

Here is my PHP code, which Does receive correctly, with color and
formatting, in Yahoo mail, but not gmail.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<title>PHP Guestbook</title>
</head>
<body>

<h1>mailtest</h1>
<?php

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

$msg = "<h2 style='color:red; background-color: Fuchsia; border: thick
dotted; border-color: Blue; font-family: sans-serif; font-style:
italic; margin-left: 20%; padding: 20; margin-right: 30%;'>Test of
formatted email from <br>Just Health Now server, with html headers</
h2>";
echo ($msg);

mail("se*****@yahoo.com","no damn color",$msg,$headers);
?>
</body>
</html>

Apr 30 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Apr 29, 8:31 pm, cybervigilante <cybervigila...@gmail.comwrote:
I sent HTML formatted email, using PHP, to my Yahoo address from my
server, and it came out fine, styles and all. I sent it to my gmail
address to test it and all I see is the raw html code. But I do get
formatted email in gmail, so I know people make it work somehow. I'm
looking right at a gmail message that I copied to Dreamweaver and it's
using Strong and Red text attributes that work in gmail. But mine
don't.

What do you do different in gmail to get formatted HTML email?
In order to reduce confusion, Gmail may display HTML in plain text.
>
Here is my PHP code, which Does receive correctly, with color and
formatting, in Yahoo mail, but not gmail.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<title>PHP Guestbook</title>
</head>
<body>

<h1>mailtest</h1>

<?php

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

$msg = "<h2 style='color:red; background-color: Fuchsia; border: thick
dotted; border-color: Blue; font-family: sans-serif; font-style:
italic; margin-left: 20%; padding: 20; margin-right: 30%;'>Test of
formatted email from <br>Just Health Now server, with html headers</
h2>";
echo ($msg);

mail("sere...@yahoo.com","no damn color",$msg,$headers);

?>

</body>
</html>

Apr 30 '07 #2

P: n/a
Hello,

on 04/29/2007 10:31 PM cybervigilante said the following:
I sent HTML formatted email, using PHP, to my Yahoo address from my
server, and it came out fine, styles and all. I sent it to my gmail
address to test it and all I see is the raw html code. But I do get
formatted email in gmail, so I know people make it work somehow. I'm
looking right at a gmail message that I copied to Dreamweaver and it's
using Strong and Red text attributes that work in gmail. But mine
don't.

What do you do different in gmail to get formatted HTML email?
You should not send HTML mail messages with a plain text alternative
part. When you do that, mail systems may take it as a sign of spam, as
real mail programs do not send messages that way.

You should compose a multipart/alternative message that contains a text
part and an HTML mail part.

If you do not know how to do that, take a look at this MIME message
class as it makes that task much simpler. Try the
test_simple_html_mail_message.php script.

http://www.phpclasses.org/mimemessage
--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
Apr 30 '07 #3

P: n/a
Manuel Lemos wrote:
Hello,

on 04/29/2007 10:31 PM cybervigilante said the following:
>I sent HTML formatted email, using PHP, to my Yahoo address from my
server, and it came out fine, styles and all. I sent it to my gmail
address to test it and all I see is the raw html code. But I do get
formatted email in gmail, so I know people make it work somehow. I'm
looking right at a gmail message that I copied to Dreamweaver and it's
using Strong and Red text attributes that work in gmail. But mine
don't.

What do you do different in gmail to get formatted HTML email?

You should not send HTML mail messages with a plain text alternative
part. When you do that, mail systems may take it as a sign of spam, as
real mail programs do not send messages that way.

You should compose a multipart/alternative message that contains a text
part and an HTML mail part.

If you do not know how to do that, take a look at this MIME message
class as it makes that task much simpler. Try the
test_simple_html_mail_message.php script.

http://www.phpclasses.org/mimemessage

Actually, you NEED to send both HTML and plain text. Otherwise people
who accept only plain text will not receive it. Any mail with special
encodings (such as HTML) should include a plain text version.

But did you also indicate the content was multi-part, including both
text and text/html content? Did it have the appropriate separators?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 30 '07 #4

P: n/a
Message-ID: <46**************@acm.orgfrom Manuel Lemos contained the
following:
>What do you do different in gmail to get formatted HTML email?

You should not send HTML mail messages with a plain text alternative
part. When you do that, mail systems may take it as a sign of spam, as
real mail programs do not send messages that way.
s/with/without
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Apr 30 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.