html mail

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jaunty Edward

    #1

    html mail

    HI,
    I had been trying to send a html email from the folowing script that i
    took from zend site and modified. Its working fine, but it sends some
    garbage in the end of the mail.
    I had posted this msg on the zend and other forums and also read this
    forum with some similar msg. They talked about encoding I think there
    is some problem in the encoding. I will be very thankful to someone
    who can currect the script. Remember currect, I dont want to know what
    am i Doing wrong this is because I am so tierd of trying them. Please
    I will be thankful, I understand that i should learn where am I going
    wrong but I tried all suggestions may be I am not doing it the right
    way. I will be thankful if someone can currect it or mail me the
    similar script that works fine to smilesinblues@h otpop.com.

    Regards
    Jaunty

    <?

    $headers = "From: webserver@myhos t.net\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $boundary = uniqid("HTMLDEM O");
    $headers .= "Content-Type: multipart/alternative" . "; boundary =
    $boundary\r\n\r \n";
    $headers .= "This is a MIME encoded message.\r\n\r\ n";
    $headers .= "--$boundary\r\n" . "Content-Type: text/plain;
    charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n" ;
    $headers .= chunk_split(bas e64_encode("Thi s is the plain text
    version!"));
    $headers .= "--$boundary\r\n" . "Content-Type: text/html;
    charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n" ;
    $name = stripslashes($H TTP_POST_VARS['name']);
    $email = stripslashes($H TTP_POST_VARS['email']);


    $msg = "<b>Name:</b> " .
    $name . "\nEMail: " . $email;

    $headers .= chunk_split(bas e64_encode("$ms g"));


    $sent = @mail('Mr. Jaunty<me@myema il.net>', 'Msg From My Website' ,
    $msg , $headers);
    if($sent == true) {
    header('Locatio n: send.htm');
    }
    if($sent == false) {
    header('Locatio n: notsend.htm');
    }

    ?>
  • Manuel Lemos

    #2
    Re: html mail

    Hello,

    On 07/14/2004 08:11 PM, Jaunty Edward wrote:[color=blue]
    > HI,
    > I had been trying to send a html email from the folowing script that i
    > took from zend site and modified. Its working fine, but it sends some
    > garbage in the end of the mail.
    > I had posted this msg on the zend and other forums and also read this
    > forum with some similar msg. They talked about encoding I think there
    > is some problem in the encoding. I will be very thankful to someone
    > who can currect the script. Remember currect, I dont want to know what
    > am i Doing wrong this is because I am so tierd of trying them. Please
    > I will be thankful, I understand that i should learn where am I going
    > wrong but I tried all suggestions may be I am not doing it the right
    > way. I will be thankful if someone can currect it or mail me the
    > similar script that works fine to smilesinblues@h otpop.com.[/color]

    It seems you are mistaking the message headers and body data.

    Anyway the example in the Zend site encourages you to a bad practice
    that may make your messages end up being discarded by spam filters.

    HTML messages should always have an alternative text part that is
    displayed for people with HTML capable mail programs. Without an
    alternative text part the message does not look like it was sent by a
    user using a real mail client, and so less tolerant spam filters discard it.

    The correct way to do it is to compose multipart/alternative. If you
    want to know how to send such messages without much effort, you may want
    to tr this class that even comes with an example on how to compose and
    send HTML messages properly:

    http://www.phpclasses.org/mimemessage


    --

    Regards,
    Manuel Lemos

    PHP Classes - Free ready to use OOP components written in PHP
    http://www.phpclasses.org/

    PHP Reviews - Reviews of PHP books and other products
    http://www.phpclasses.org/reviews/

    Metastorage - Data object relational mapping layer generator

    Comment

    • Jaunty Edward

      #3
      Re: html mail

      HI,
      thanks for the help, I got a script that works fine, if any one is
      future want a script for mail me i will mail you.
      Thanks
      Jaunty

      Comment

      Working...