Page 1 of 1

Problems sending HTML emails

Posted: Sun Mar 20, 2005 10:30 am
by mzfp2
Hi All,

I've just copied a newsletter script I've been running for a while from my previous host to a new host and ran into a problem.

Emails are being received as texts rather than HTML, (didn't have this problem on my previous host), I dont if the problem is related toi the fact that my new host adds some text to the email itself .. Here's what I receive in my inbox :



Content-Type: text/html

Message-Id: <E1DD3Jq-0006bs-00@venus.webfusion.co.uk>
Date: Sun, 20 Mar 2005 16:30:26 +0000

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head>

<body>
Newsletter
<img src="http://stopandshop.me.uk/news/images/test.jpg" width="120" height="200" />
</body>
</html>


Message-ID and Date appear because the host seems to be writing this to every email.

Is there any way to force the email to be a html email?

Kind Regards
Musaffar
http://www.good2shop.co.uk

Posted: Sun Mar 20, 2005 10:34 am
by feyd
post the code that generates this email

Posted: Sun Mar 20, 2005 10:37 am
by mzfp2
The code is as follows

Code: Select all

$subject = 'Stop&Shop Nesletter';
      $message = ParseTemplate($template, $ent);
      $to      = $row[email];
      $xtra    = "From: info@stopandshop.me.uk (StopAndShop)\r\n";
      $xtra   .= "Content-Type: text/html \r\n";
      $mail_result = @mail($to, $subject, $message, $xtra);

However I doubt it has much to do with the code, as this code worked perfectly on my previous host.

Kind Regards
Musaffar
http://www.good2shop.co.uk

Posted: Sun Mar 20, 2005 10:39 am
by feyd
try removing the trailing line-feed and carriage return in your header data.

Posted: Sun Mar 20, 2005 10:43 am
by mzfp2
I've removed the

Code: Select all

\r\n
from the header data in both lines, now i get the following text in my email

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head>

<body>
Newsletter
<img src="http://stopandshop.me.uk/news/images/test.jpg" width="120" height="200" />
</body>
</html>

But not displaying as HTML :(

Posted: Sun Mar 20, 2005 10:45 am
by feyd
I didn't say from both lines.. only the last one, the content-type one..

Posted: Sun Mar 20, 2005 10:47 am
by mzfp2
Hi Sorry I shoud've mentioned earlier that I have already tried removing the the carriage return and linefeed from the content-type data, to no avail.

Posted: Sun Mar 20, 2005 10:52 am
by feyd
post the full source of the email.. headers and all..

Posted: Sun Mar 20, 2005 10:58 am
by mzfp2
Headers are


Return-Path: <stopshop@venus.webfusion.co.uk>
Delivered-To: admin@alljammin.com
Received: (qmail 29072 invoked from network); 20 Mar 2005 16:36:27 -0000
Received: from venus.webfusion.co.uk (212.67.202.12)
by 0 with SMTP; 20 Mar 2005 16:36:27 -0000
Received: from stopshop by venus.webfusion.co.uk with local (Exim 3.36 #1)
id 1DD3PX-0006wY-00
for admin@alljammin.com; Sun, 20 Mar 2005 16:36:19 +0000
To: admin@alljammin.com
Subject: Stop&Shop Nesletter
From: info@stopandshop.me.uk (StopAndShop)


email code is :

Content-Type: text/html

Message-Id: <E1DD3PX-0006wY-00@venus.webfusion.co.uk>
Date: Sun, 20 Mar 2005 16:36:19 +0000


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>
Newsletter
<img src="http://stopandshop.me.uk/news/images/test.jpg" width="120" height="200" />
</body>
</html>




Obtained this from Outlook. Hope it helps

Posted: Sun Mar 20, 2005 11:03 am
by feyd
that looks like the old one... it would appear you are getting a double line break after your From attribute. Tried using just \n ?

Posted: Mon Mar 21, 2005 10:38 am
by mzfp2
Thanks, thats solved the problem, many thanks for your help :)

Musaffar
http://www.good2shop.co.uk