Solved

PHP HTML Email Not Working

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
RHEL7 - Error installing docker compose 2 219
Deny sending to more than 2 recipients in Exchange 2016 2 50
Php variable to be sent back 3 35
Can't Find The Code 15 22
This article discusses how to create an extensible mechanism for linked drop downs.
As cyber crime continues to grow in both numbers and sophistication, a troubling trend of optimization has emerged over the last year.
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.
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.

752 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