Web Analytics Made Easy -
StatCounter What doctype should I use for html email ? - CodingForum

Announcement

Collapse
No announcement yet.

What doctype should I use for html email ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • What doctype should I use for html email ?

    Hi
    I want to send an html email.

    To do this do I start off the email with a doctype ?

    e.g.

    PHP Code:
    $message "
    <!DOCTYPE HTML PUBLIC "
    -//W3C//DTD HTML 4.01 Transitional//EN"
     
    "http://www.w3.org/TR/html4/loose.dtd">
    <
    html>
    <
    head>
    <
    titlea title</title>
    <
    meta name="keywords" content="some keywords">
    <
    meta name="description" content=" a description">
    <
    meta name="allow-search" content="yes">
    <
    meta name="audience" content="all">
    <
    meta name="revisit-after" content="4 Days">
    <
    meta name="robots" content="all, index, follow">
    <
    meta name="copyright" content="mysite.com">
    <
    meta name="Rating" content="General">
    <
    meta name="Language" content="en">
    <
    meta name="distribution" content="global">
    <
    meta name="classification" content="internet marketing">
    <
    meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <
    meta http-equiv="Content-Script-Type" content="text/javascript">
    </
    head>
    <
    body>".$message."
    </body>
    </
    html>
    "; 
    Is the doctype I used OK or is their a special one for emails ?

    Should I use all that meta tag stuff of is it unnecessary ?

    Would appreciate some help on this as I am new to this

    Thanks
    If you want to attract and keep more clients, then offer great customer support.

    Support-Focus.com. automates the process and gives you a trust seal to place on your website.
    I recommend that you at least take the 30 day free trial.

  • #2
    It doesnt matter which doctype you use. I generally use XHTML. But its upto you.

    What do you mean html email? You can't get html to send email. Or is it an html form you want that will send the data to another script via post. Or maybe just an html link to an email e.g

    Code:
    <a href="mailto:[email protected]">Email</a>
    Which is the closest thing HTML has to email. Which is a bad idea if you don't want to recieve spam. In any case you doctype is irrelevant. The doctype only effects how the syntax of your code should be and how a browser will interpret your code.
    You can not say you know how to do something, until you can teach it to someone else.

    Comment


    • #3
      Originally posted by timgolding View Post
      What do you mean html email? You can't get html to send email. Or is it an html form you want that will send the data to another script via post. Or maybe just an html link to an email e.g

      Code:
      <a href="mailto:[email protected]">Email</a>
      Which is the closest thing HTML has to email. Which is a bad idea if you don't want to recieve spam. In any case you doctype is irrelevant. The doctype only effects how the syntax of your code should be and how a browser will interpret your code.
      Perhaps you misunderstood. The OP wants to send email in HTML format(versus text format). See example #4 of the mail() function in the PHP manual.

      Originally posted by jeddi View Post
      Is the doctype I used OK or is their a special one for emails ?
      As a general rule you shouldn't -need- a doctype for sending emails because most email clients tend to use a combination of HTML4 - loose. Some of them ignore or strip the doctype anyway, so you shouldn't need one. Just keep your layout as simple as possible to avoid problems.
      Originally posted by jeddi View Post
      Should I use all that meta tag stuff of is it unnecessary ?
      All of the search stuff is unnecessary.. you can keep the content-types, expiration, and things of that nature.
      Last edited by Inigoesdr; Apr 5, 2009, 05:00 PM.

      Comment


      • #4
        Oops sorry. Didn't think that one through.
        You can not say you know how to do something, until you can teach it to someone else.

        Comment


        • #5
          OK, thanks for that.

          I remember reading somewhere that with an html email, you should also
          send a text only version.

          Is that true ? How do I do it. ?

          So this is my code so far:

          Are the headers correct for what I am trying to do ?

          PHP Code:
          $headers ="MIME-Version:1.0\r\n";
          $headers .="content-type:text/html; Charset=iso-8859-1\r\n";
          $headers .= "From: " "$fm_name"<" "$fm_email">\n";
          $headers .= "Return-Path: <" "$to">\n";
          $headers .= "Error-To: <" "$to">\n";
          $headers .= "X-Sender: <" "$to">\n";
          $headers .= "X-Mailer: PHP v".phpversion()."\n";


          // subject
          $subjectnl2br($subject);
             
          $message=nl2br($message);
          $message=eml_bbcode($message);

          $message "
          <html>
          <head>
          <title> a title</title>
          <meta name="
          audience" content="all">
          <meta name="
          revisit-after" content="4 Days">
          <meta name="
          robots" content="allindexfollow">
          <meta name="
          copyright" content="mysite.com">
          <meta name="
          Rating" content="General">
          <meta name="
          Language" content="en">
          <meta name="
          distribution" content="global">
          <meta name="
          classification" content="internet marketing">
          <meta http-equiv="
          Content-Type" content="text/htmlcharset=UTF-8">
          <meta http-equiv="
          Content-Script-Type" content="text/javascript">
          </head>
          <body>"
          .$message."
          </body>
          </html>
          "
          ;  


          mail($to$subject$message$headers); 
          So how or where do I add a text version and
          are my headers correct ?

          Thanks
          If you want to attract and keep more clients, then offer great customer support.

          Support-Focus.com. automates the process and gives you a trust seal to place on your website.
          I recommend that you at least take the 30 day free trial.

          Comment


          • #6
            Originally posted by jeddi View Post
            OK, thanks for that.

            I remember reading somewhere that with an html email, you should also
            send a text only version.

            Is that true ? How do I do it. ?
            mail is a distinct protocol is plain text and have nothing to do with html.

            http://www.faqs.org/rfcs/rfc2822
            http://www.php.net/manual/en/function.mail.php

            multipart mime message can include a text/html part
            you can find here a simple explanation how you can do:

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

            best regards

            Comment


            • #7
              OK, thanks I read info from the links you gave me.

              Just one question,

              in my headers ( here ) :

              Code:
              $headers  = 'MIME-Version: 1.0' . "\r\n";
              $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
              $headers .= 'From: ' . "$fm_name" . "<" . "$fm_email" . ">\r\n";
              $headers .= "Return-Path: <" . "$to" . ">\r\n";
              $headers .= "Error-To: <" . "$to" . ">\r\n";
              $headers .= "X-Sender: <" . "$to" . ">\r\n";
              $headers .= "X-Mailer: PHP v".phpversion()."\r\n";
              Shouldn't the Return-Path be the $fm_email
              rather than the $to meail address ?

              Same goes for Error-To and X-Sender doesn't it ?

              I copied these headers from somewhere, but
              it doesn't look right to me - what do you guys think ?

              I am new to this so would appreciate an experienced
              input on this

              Thanks
              If you want to attract and keep more clients, then offer great customer support.

              Support-Focus.com. automates the process and gives you a trust seal to place on your website.
              I recommend that you at least take the 30 day free trial.

              Comment


              • #8
                timgolding ? did you read the post?

                @timgolding ?

                The poster clearly states that they want to send an html email and that they don't know which DOCTYPE declaration to use (or if they should include one at all) and if so whether to include meta tags etc.

                Why do you assume the poster is as confused as you seem to be.

                In any case you doctype is irrelevant
                It is not irrelevant at all. e.g. from

                http://www.emailonacid.com

                Warning Line 1, Column 1: missing <!DOCTYPE> declaration
                So in answer to the poster's actual question (as opposed to whatever you want to pretend you read) :

                http://stackoverflow.com/questions/4...ting-html-mail

                ...should help, but basically - most email clients will ignore the doctype, but just because they do whatever they want does not mean we all should. So include a doctype that matches your html (and potentially css), no point using meta tags in an email though (as far as I can see).

                Good luck.




                Originally posted by timgolding View Post
                It doesnt matter which doctype you use. I generally use XHTML. But its upto you.

                What do you mean html email? You can't get html to send email. Or is it an html form you want that will send the data to another script via post. Or maybe just an html link to an email e.g

                Code:
                <a href="mailto:[email protected]">Email</a>
                Which is the closest thing HTML has to email. Which is a bad idea if you don't want to recieve spam. In any case you doctype is irrelevant. The doctype only effects how the syntax of your code should be and how a browser will interpret your code.

                Comment


                • #9
                  Apologies to @timgolding

                  I myself only just read whole thread and saw your apology for not reading the OP properly. whoops.

                  Comment

                  Working...
                  X