Forum Moderators: coopster

Message Too Old, No Replies

PHP mail() function

Not showing HTML - Headers Issue?

         

wfernley

1:35 pm on Aug 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey everyone,

I recently moved hosts and I am now using QMail instead of POSTFIX. My PHP mail() functions that used to work, now do not show HTML. Here are my mail() headers:

$headers = "From: \"My Name\" <myemail@test.com>\r\n";
$headers .= "Reply-To: myemail@test.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 8bit;\r\n\r\n";
$headers .= "\r\n";
mail("sendto@test.com", "Subject Goes Here", "Message Containing HTML Code", $headers);

When I get emails, it prints this at the top of the email:

Content-Type: text/HTML; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit;

I was wondering if my headers are incorrect?

Thanks in advance for your help!

Wes

jatar_k

4:56 pm on Aug 23, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



have you tried moving them around?

I had one where this order was the only I could make work

To
From
Subject
Return-Path
Reply-To
Content-type
Mime-Version

having Mime-Version last was the key. Though I was injecting this into the qmail queue, not using the mail function.

try moving them around and see what happens

wfernley

8:48 pm on Aug 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah I tried moving them around but it was a no go. Once I removed the line:

$headers .= "Content-Transfer-Encoding: 8bit;\r\n\r\n";

It worked fine. Strange isn't it.

jatar_k

10:13 pm on Aug 23, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



with mail headers I just keep testing

it seems to be a different answer every time

ah well, glad you fixed it

wfernley

8:21 pm on Aug 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for your help!

I think it all depends on what you are using as your sendmail. I switched dedicated servers and my new one uses Qmail so it must handle the headers differently than Postfix.

Thanks again! :)