store HTML is a text field in a table on a MySQL Database

Discussion in 'MySQL' 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.

    ANy suggestions?
     
    woocha, Sep 14, 2007 IP
  2. hamidof

    hamidof Peon

    Messages:
    619
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this: (if you are using PHP)

    
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: Your Name <youremail@yourdomain.com>' ."\r\n"
    	.'Reply-To: youremail@yourdomain.com' ."\r\n"
    	.'X-Mailer: PHP' ."\r\n";
    $subject = 'Subject';
    $body = 'The HTML text from DB';
    $email = 'someemail@somedomain.com';
    mail($email, $subject, $body, $headers);
    
    PHP:
     
    hamidof, Sep 14, 2007 IP
  3. hamidof

    hamidof Peon

    Messages:
    619
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You need to send the HTML mime type along with the email so the email client knows the message is HTML.
     
    hamidof, Sep 14, 2007 IP
  4. woocha

    woocha Peon

    Messages:
    107
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thanks a lot....I'll add that in there
    $headers = 'MIME-Version: 1.0' . "\r\n";:)
     
    woocha, Sep 15, 2007 IP