Solved

PHP HTML Email Not Working

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Email signatures have numerous marketing benefits. Here are 8 top reasons to turn your email signature into a marketing channel.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now