problem by using of the mail function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pavani1
    Banned
    New Member
    • Mar 2008
    • 4

    problem by using of the mail function

    hi,

    i used the below code i got the message field with the html tags. plz tell that what's the problem in my code. [php]<?php
    $to ='$_POST[email_addr]";
    $subject = "Site Registration Confirmation";
    $message = "<html>
    <head>
    <title>Site Registration Confirmation</title>
    </head>

    <body style=font-family:verdana, arial; font-size: .8em;>
    <a title=Confirm Comment
    href=http://www.website.com/confirm.php?c=' .$confirmationC ode.'>http://www.website.com/confirm.php?c=' .$confirmationC ode.'</a>
    </body>
    </html>';
    $headers = "MIME-Version: 1.0\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\n";
    $headers .= "X-Priority: 3\n";
    $headers .= "X-MSMail-Priority: Normal\n";
    $headers .= "X-Mailer: php\n"
    $from = "me@example.com ";
    $headers = "From: $from";
    mail($to,$subje ct,$message,$he aders);
    ?>[/php]Use code tags!!!
    Last edited by ronverdonk; Mar 28 '08, 05:52 PM. Reason: code tags
  • zorgi
    Recognized Expert Contributor
    • Mar 2008
    • 431

    #2
    Try replacing:

    Originally posted by pavani1
    [php]$message = "<html>
    <head>
    <title>Site Registration Confirmation</title>
    </head>
    <body style=font-family:verdana, arial; font-size: .8em;>
    <a title=Confirm Comment
    href=http://www.website.com/confirm.php?c=' .$confirmationC ode.'>http://www.website.com/confirm.php?c=' .$confirmationC ode.'</a>
    </body>
    </html>';
    ?>[/php]
    with:

    [PHP]

    $message = "<html>";
    $message .= "<head>";
    .
    .
    .
    $message .= "<a href=\"http://www.website.com/confirm.php?c=$ confirmationCod e\">";
    $message .= "http://www.website.com/confirm.php?c=$ confirmationCod e</a><br />";
    .
    ...........etc
    [/PHP]

    But I don't think you need all this tags <html> <title> <head> <body>to send HTML email. You are best keeping your HTML mails as simple as possible.

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      Please use code tags when posting code.

      Regards.

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        Please enclose your posted code in [code] tags (See How to Ask a Question).

        This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

        Please use [code] tags in future.

        MODERATOR

        Comment

        • aktar
          New Member
          • Jul 2006
          • 105

          #5
          Hi Pavani,


          Your problem is in the following line:

          [PHP]

          $headers = "From: $from";

          [/PHP]

          Basically you are replacing all the other info, ie mime, content type etc with FROM: $from instead of appending to it.

          The correct way to do it is:

          [PHP]

          $headers .= "From: $from"; //notice the .=

          [/PHP]


          Regards

          Comment

          Working...