Solved

PHP HTML Email Not Working

Posted on 2010-09-02
4
706 Views
Last Modified: 2012-08-13
Hello,

I have a script that should send html email.   it works for all webmail clients and such like gmail and yahoomail however in outlook all it does is display code

Here is the code im using
<? 
    //change this to your email. 
    $to = "xxxx@xxxxxx.com"; 
    $from = "support@xxxxxx.com"; 
    $subject = "Hello! This is HTML email"; 

    //begin of HTML message 
    $message = '
<html> 
  <body bgcolor="#DCEEFC"> 
    <center> 
        <b>Looool!!! I am reciving HTML email......</b> <br> 
        <font color="red">Thanks Mohammed!</font> <br> 
        <a href="http://www.maaking.com/">* maaking.com</a> 
    </center> 
      <br><br>*** Now you Can send HTML Email <br> Regards<br>MOhammed Ahmed - Palestine 
  </body> 
</html> 
'; 
   //end of message 
    $headers  = "From: $from\r\n"; 
    $headers .= "Content-type: text/html\r\n"; 

    //options to send to cc+bcc 
    //$headers .= "Cc: [email]maa@p-i-s.cXom[/email]"; 
    //$headers .= "Bcc: [email]email@maaking.cXom[/email]"; 
     
    // now lets send the email. 
    mail($to, $subject, $message, $headers); 

    echo "Message has been sent....!"; 
?>

Open in new window


Here is what i get in outlook
Content-type: text/html 
Message-Id: <20100903042819.E06651210E7@xxxxxx.com>
Date: Fri,  3 Sep 2010 04:28:19 +0000 (UTC)


 
<html>  
  <body bgcolor="#DCEEFC">  
    <center>  
        <b>Looool!!! I am reciving HTML email......</b> <br>  
        <font color="red">Thanks Mohammed!</font> <br>  
        <a href="http://www.maaking.com/">* maaking.com</a>  
    </center>  
      <br><br>*** Now you Can send HTML Email <br> Regards<br>MOhammed Ahmed - Palestine  
  </body>  
</html>

Open in new window


What can i do to fix this?  What other info do you need?
0
Comment
Question by:bretterer
  • 2
4 Comments
 
LVL 16

Accepted Solution

by:
santoshmotwani earned 250 total points
ID: 33593662

<? 
    //change this to your email. 
    $to = "xxxx@xxxxxx.com"; 
    $from = "support@xxxxxx.com"; 
    $subject = "Hello! This is HTML email"; 

    //begin of HTML message 
    $message = '
<html> 
  <body bgcolor="#DCEEFC"> 
    <center> 
        <b>Looool!!! I am reciving HTML email......</b> <br> 
        <font color="red">Thanks Mohammed!</font> <br> 
        <a href="http://www.maaking.com/">* maaking.com</a> 
    </center> 
      <br><br>*** Now you Can send HTML Email <br> Regards<br>MOhammed Ahmed - Palestine 
  </body> 
</html> 
'; 
   //end of message 
    $headers  = "From: $from\n"; 
    $headers .= "Content-type: text/html\n"; 

    //options to send to cc+bcc 
    //$headers .= "Cc: [email]maa@p-i-s.cXom[/email]"; 
    //$headers .= "Bcc: [email]email@maaking.cXom[/email]"; 
     
    // now lets send the email. 
    mail($to, $subject, $message, $headers); 

    echo "Message has been sent....!"; 
?>

Open in new window

0
 
LVL 16

Expert Comment

by:santoshmotwani
ID: 33593663
Try above code plz
0
 
LVL 3

Expert Comment

by:ovi_mihai
ID: 33593666

Try

$headers  = "From: $from\n";                        //here missing /r
$headers .= "Content-type: text/html\r\n";

aparently outlook doesn't like /r only on the last header line

http://www.bigresource.com/Tracker/Track-php-Ho18Kdzs/


if it doesn't work, try a more complex header

$headers = 'Content-Type: text/html; charset="iso-8859-1"' . "\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'From:  <email@email.com>' . "\n";
$headers .= 'To: email@email.com' . "\n";
$headers .= 'Reply-To: email@email.com'. "\r\n";

Open in new window

0
 
LVL 3

Author Closing Comment

by:bretterer
ID: 33593682
Thank you so much.   Wish i had asked a few days ago when this issue started.  Removing the \r from it worked perfect!!!!!!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Fine Tune your automatic Updates for Ubuntu / Debian
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question