Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML Formatting Using Heredoc and Mail()

Status
Not open for further replies.

csatterwhite

Programmer
Aug 4, 2010
4
Here's the line of code I am using:

Code:
$message = <<<EMAIL
<html>
<body>
<h1 style="background:#546D81; color:#ffffff; font-size:14px; padding:10px;">$subject</h1>
<p style="font-size:12px;"><strong>From:</strong> $firstname $lastname</p>
<p style="font-size:12px;"><strong>Sender Email:</strong>$email</p>
<h2 style="font-size:12px;">Comments:</h2>
<p style="font-size:11px;">$comments</p>
</body>
</html>
EMAIL;

The formatting shows up in gmail (as an example) but does not show in Outlook or Mac OS X Entourage.

I am also setting headers like so:

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

Any ideas?
 
how mail clients handle html messages is entirely idiosyncratic. it's not a php question.
 
The question was not how email clients handle email (I understand the idiosyncrasies), the question was a php question because I wasn't sure if there was something wrong with the code or something I was leaving out that maybe someone here knew of.

It makes sense if Google is picking it up with proper formatting the codes working, I wasn't sure because of using heredoc instead of normal variables to set the HTML was there something I was missing.

I'll keep looking elsewhere. Thanks.

=======================
Carl Satterwhite
Visual Designer
 
I think I have narrowed it down to something to do with:


"quoted_printable_encode"


Does anyone have any experience with this and how to implement on above code?

=======================
Carl Satterwhite
Visual Designer
 
there is nothing wrong with the code and I do not believe that the encoding of the text will make any difference to the formatting.

if you wish to have the best chance at presenting consistently across mail clients then i suggest you turn to phpmailer.

 
I don't know if this helps you at all, but I define the first line of headers (IE '=' only), then "sub-define" the rest (IE '.='). Here's what my code looks like, and when I send an email it works in outlook, web based clients (gmail), outlook express, etc...

Code:
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: <" . $_SESSION['web_email'] . ">" . "\r\n";
			"Reply-To: " . $_SESSION['web_email'] . "" . "\r\n" .

Beware of hackers bearing executables. Happy Hunting. 'irc.2600.net'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top