Solved

PHP HTML Email Not Working

Posted on 2010-09-02
4
709 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 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
As cyber crime continues to grow in both numbers and sophistication, a troubling trend of optimization has emerged over the last year.
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 …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

622 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