[thelist] PHP mail headers problem....

Hans Zaunere zaunere at yahoo.com
Fri May 24 13:11:00 CDT 2002


Without wading through the regular expressions, I see when you generate
$header you are using only "\n"...  you need "\r\n" after every line of
the header... and if you generate the body and header yourself, you
need "\r\n\r\n" at the last header line.

HTH,

Hans Z.
New York PHP
http://nyphp.org


--- CDitty <mail at redhotsweeps.com> wrote:
> I am having problems with PHP mail headers. I am successfully getting
> the
> MIME-Version and Content-type, but when I insert them into the
> forwarded
> email message, the headers show within the email itself. Below is the
> code
> I am using.
>
> // To email address
> if(substr($lines[$i], 0, 2) == "To"){
>          $To = substr($lines[$i], 4, strlen($lines[$i]));
>          eregi("([A-Z0-9\.\-]+@[A-Z0-9\.\-]+\.[A-Z\.]+)", $To, $To);
> }elseif(substr($lines[$i], 0, 4) == "From"){// From email address
>          $From = substr($lines[$i], 6, strlen($lines[$i]));
>          eregi("([A-Z0-9\.\-]+@[A-Z0-9\.\-]+\.[A-Z\.]+)", $From,
> $From);
> }elseif(substr($lines[$i], 0, 7) == "Subject"){// Email subject
>          $Subject = substr($lines[$i], 9, strlen($lines[$i]));
> }elseif(substr($lines[$i], 0, 12) == "MIME-Version"){// Email subject
>          $Mime_Version = substr($lines[$i], 14, strlen($lines[$i]));
> }elseif(substr($lines[$i], 0, 12) == "Content-Type"){// Email subject
>          $Content_Type = substr($lines[$i], 14, strlen($lines[$i]));
> }
>
> if(IsSet($Mime_Version)){
>          $Mime_Version = "MIME-Version: $Mime_Version\r\n";
> }
> if(IsSet($Content_Type)){
>          $Content_Type = "Content-type: $Content_Type\r\n";
> }
>
> $to = "$user_email[0]";
> $subj = "$Subject";
> $msg = "$Message";
> $headers = "From: $From[1]\n";
> $headers .= "$Mime_Version\n";
> $headers .= "$Content_Type\n";
> mail($to, $subj, $msg, $headers);
>
> This is what the email looks like.
>
> Return-Path: <mail>
> Received: (from mail at localhost)
> by redhotsweeps.com (8.9.3/8.9.3) id VAA27003;
> Thu, 23 May 2002 21:23:51 -0500
> Date: Thu, 23 May 2002 21:23:51 -0500
> Message-Id: <200205240223.VAA27003 at redhotsweeps.com>
> To: XXXXXXX at redhotsweeps.com
> Subject: test
> From: XXXXXXX at redhotsweeps.com
> Status:
>
> Content-type: text/plain; charset="us-ascii"; format=flowed
>
> test 1234
>
>
> Can anyone give me any tips?
>
> Thanks
> CDitty
>
>
> --
> For unsubscribe and other options, including
> the Tip Harvester and archive of thelist go to:
> http://lists.evolt.org Workers of the Web, evolt !


__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com



More information about the thelist mailing list