Results 1 to 2 of 2

Thread: html mail sent as plain

  1. #1
    Join Date
    Aug 2006
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default html mail sent as plain



    I have a script to send email with html, but when its recieved the email becoimes plain text and looks awful. Here's the code (the varibel "id" is passed from an earlier page)

    $result = mysql_query("SELECT * FROM newsletters WHERE id='$id'");
    while ($row = mysql_fetch_array($result, MYSQL_BOTH))
    {
    $subject = $row["name"];
    $message = $row["content"];

    $wwwtext = ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html><head><title>$subject</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"></head><body>$message</body></html>");
    }

    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: newsletter@' . $_SERVER['SERVER_NAME'] . "\r\n" .
    'Reply-To: newsletter@' . $_SERVER['SERVER_NAME'] . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

    $link = mysql_query("SELECT * FROM users WHERE status='subscribed'");
    while ($r = mysql_fetch_array($link, MYSQL_BOTH))
    {
    $email = $r["email"];
    $mail = mail($email, $subject, $wwwtext, $headers);
    }

  2. #2
    Join Date
    Aug 2006
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I got it. These two links will help anyone else having this problem.

    http://www.zend.com/zend/spotlight/s...emailpart1.php

    http://www.phpbuilder.com/columns/kartic20000807.php3

    I must have gone through about fifty websites (4 days and the loss of my last few black hairs) with tutorials, tips, etc, before I found these which explain boundaries, content description and encoding.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •