[thelist] PHP mail headers

Jon Haworth jhaworth at witanjardine.co.uk
Wed Sep 26 12:20:32 CDT 2001


I think you'll need two \n's after the headers.

Here's how I do it:

<?php
$sendto   = "postmaster at 127.0.0.1";
$subject  = "Test HTML email";
$headers  = "Content-Type: text/html; charset=iso-8859-1\n";
$headers .= "From: George <president at whitehouse.gov>\n";
$headers .= "Reply-to: George <president at whitehouse.gov>\n";
$headers .= "\n";
$message  = "<html>";
$message .= "<head>";
# more message
$message .= "</html>";
mail ($sendto, $subject, $message, $headers);
?>

This works fine with PHP 4.0.6, Linux 2.4.5, and Sendmail 8.9.something -
give me a shout if it chokes on your setup.

Cheers
Jon


-----Original Message-----
From: // kerin | airside.co.uk [mailto:kerin at airside.co.uk]
Sent: 26 September 2001 16:23
To: thelist at lists.evolt.org
Subject: [thelist] PHP mail headers


Hi everyone,

I'm using PHP to send out mail using the mail() function.

Here's a snippet of my code:

while($row = mysql_fetch_array($sql_result)) {
     $email = $row["email"];
     $firstname = $row["firstname"];
     $secondname = $row["secondname"];

     $headers ="From: mailinglist at pauloakenfold.com\r\nReply-To: 
mailinglist at pauloakenfold.com\r\nTo: '".$firstname." ".$secondname."' 
<".$email.">";

     mail($email,$subject,$body,$headers);
}

now, the mail sounds out fine, except that the mail headers don't 
work. The most important of these is the From: field. At the minute, 
the From field in the received email is our ISPs equivalent of 
root at localhost - not desirable.

I've tried every permutation on the From field I can think of -

from: mailinglist at pauloakenfold.com <pauloakenfold.com>
from: pauloakenfold.com <mailinglist at pauloakenfold.com>
from: mailinglist at pauloakenfold.com
from: <mailinglist at pauloakenfold.com>

And I still get root at localhost in the From: field.

Oh, and all of my so-called "header" fields just get dumped in the 
message body.

Where am I going wrong?


**********************************************************************
'The information included in this Email is of a confidential nature and is 
intended only for the addressee. If you are not the intended addressee, 
any disclosure, copying or distribution by you is prohibited and may be 
unlawful. Disclosure to any party other than the addressee, whether 
inadvertent or otherwise is not intended to waive privilege or confidentiality'

**********************************************************************





More information about the thelist mailing list