Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PHP HTML Email Not Working

Posted on 2010-09-02
4
Medium Priority
?
712 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 16

Accepted Solution

by:
santoshmotwani earned 1000 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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
The viewer will learn how to count occurrences of each item in an array.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

670 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