Forum Moderators: coopster

Message Too Old, No Replies

mail function - html tags appearing appearing in mail body

html tags appearing in mail body

         

saad

3:40 pm on Feb 8, 2007 (gmt 0)

10+ Year Member



<?php
// multiple recipients
$to = 'abc@domain.com;

// subject
$subject = 'eNewsletter - January 2007';

// message
$message = file_get_contents("index.htm");

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: <abc@domain.com>' . "\r\n";
$headers .= 'From: Saad <saad@domain.com>' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
?>

Result: HTML tags appearing in outlook instead of proper layout.

Saad;

jatar_k

3:49 pm on Feb 8, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld saad,

have you taken a look at the message source to see where the headers may be falling apart?

saad

3:58 pm on Feb 8, 2007 (gmt 0)

10+ Year Member



Thanks for the reply. Message source is

<html>
<head>
<title>Newsletter - February 2007</title>
<link href="text.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="600" ......

</body>
</html>

Before it was

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Newsletter - February 2007</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="text.css" rel="stylesheet" type="text/css">
</head>

<body>
......
</body>
</html>

but result is same in both cases.

saad

4:03 pm on Feb 8, 2007 (gmt 0)

10+ Year Member



I am sorry, I have realized that problem is somewhat different from what I have stated earlier, let me paste some text from the output that i am seeing in outlook.

<http://www.domain.com> <http://www.domain.com/support.php> Contact Us <http://www.domain.com/support.php>
<http://www.domain.com/eNewsletters/2006_FEB/images/header_pic.gif>
--> Issue - February 2007
<http://www.domain.com/eNewsletters/2006_FEB/images/logo.gif>
Publications<http://www.domain.com/eNewsletters/2006_FEB/images/publications.gif>

I see the URLs plus enclosed text (hyperlinks) in my output.

Saad;

jatar_k

4:11 pm on Feb 8, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



do you have your outlook to display as text only, I think there is a setting for that

what I was actually wondering about was looking at the message source with headers included to see if the headers you set are actually there or that they aren't being changed

saad

4:15 pm on Feb 8, 2007 (gmt 0)

10+ Year Member



Problem solved, Outlook was treating message as SPAM/JUNK and upon moving message to inbox, everything appeared just right, but i wonder why CSS is not in action in outlook, do i have to use font tags for styling to be appeared in outlook.

bomburmusicmallet

5:01 pm on Feb 8, 2007 (gmt 0)

10+ Year Member



i embed my styles right into my emails, and it always works.