Email HTML from a text field in a table on a MySQL Database

Discussion in 'PHP' started by woocha, Sep 14, 2007.

  1. #1
    I am emailing a field from a MySQL DB table. The field type is text. Basically, it is an accept email. How can I make it so the email sent is capable of emailing HTML to make the message more attractive?


    I have already tried to insert < html > into the text field, but that doesn't work....The received email, just diplays the text < html > and then the rest of the text.

    Here is the email php code that I am using:
    if ($action == "decline")
    {
    	$query	= "delete from orders where id=$id and merchant=$merchant";
    	mysql_query( $query);
    
    if ($sendemail == "yes") 
    {
    
      mail("\"$name\" <$email>", 
         "Your order has been declined!", 
         stripslashes($r['emaildecline']),
          "From: \"".$r['company_name']."\" <".$r['email'].">\nReply-To: ".$r['email']); 
    }
    }
    Code (markup):

     
    woocha, Sep 14, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
  3. woocha

    woocha Peon

    Messages:
    107
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    As it turns out, the problem was in the PHP code, NOT the MySQL table.....I was missing a few step in the PHP and needed to rewrite the headers to my Mail() function...Everything is working great now, and thank you all for the help along the way.


    
    $company_name = $r['company_name'];
    $company_email = $r['email'];	
    if ($action == "decline")
    {
    	$query	= "delete from orders where id=$id and merchant=$merchant";
    	mysql_query( $query);
    $message = stripslashes($r['emaildecline']);
    
    
    $headers  = "MIME-Version: 1.0 \r\n" .
                "Content-type: text/html; charset=iso-8859-1\r\n" .
                "From: $company_name <$company_email>\r\n" .
                "Reply-To: $company_email"; 
    if ($sendemail == "yes") 
    {
    
      mail("\"$name\" <$email>", 
         "Your order has been declined!", 
         $message,
          $headers); 
    }
    }
    Code (markup):
    I am only posting this so other people can fix this problem without having to go through what I went throuygh....If you have any questions, reply to this thread
     
    woocha, Sep 14, 2007 IP