Can't send HTML email from PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
karmafunk
Forum Newbie
Posts: 1
Joined: Mon Sep 22, 2008 1:03 pm

Can't send HTML email from PHP

Post by karmafunk »

I am trying to send email in HTML format using the following code but I receive the following email, with the headers in the body. Any ideas?

Code: Select all

 
        $to      =  "info@lsign.co.uk";
        $from     = $email; 
        
        $subject = '[Contact] : Website Info requested' ;
        
        $msg     = "From : $from 
" . $message;
        ini_set("sendmail_from", $from);
 
        $test = mail($to, $subject, $msg, "From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\nX-Mailer:PHP/".phpversion()." \n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1" );
 
The email sent:

Reply-To: stevegra2000@hotmail.com X-Mailer:PHP/5.1.6
MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
Message-Id: <20080922173254.D040AA4167@server88-208-236-227.lutions.co.uk>
Date: Mon, 22 Sep 2008 18:32:54 +0100 (BST)

From : stev2000@hotmail.com
Text:another test

Tel:07950567366
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Can't send HTML email from PHP

Post by josh »

this is a guess, but \r\n is a windows newline, and if the email server is linux or mac it might see that as the end of the headers segment, did you try a plain old "\n" ?
Post Reply