Changing text color in a string (email message)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kenno69
    New Member
    • Jun 2007
    • 9

    Changing text color in a string (email message)

    Hello am just a simple question.I have a contact us page that sends mail to the admin, i got it finally working but i was wondering if there is anyway to change the colour of what it sends to the admin.
    Here is what it is sending
    [PHP]$message = <<<MSG
    This message was sent from the contact us page,
    The user said,
    $_POST[message]
    this user has in anyway missused this page please contact an adminstator asap with there ip address $_SERVER[REMOTE_ADDR]
    MSG;[/PHP]
    I would like to make the $_POST[message] red
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, kenno69.

    The easiest way to do this is to use HTML. Just put span tags around the message:

    [code=php]
    <span style="color:re d;">$_POST[message]</span>
    [/code]

    For info on how to send HTML emails, check out the manual page for mail(). Look towards the middle of the page.

    Comment

    • kenno69
      New Member
      • Jun 2007
      • 9

      #3
      Thanks, but when i read my email it just shows me
      "<span style="color:re d;">am testing</span>"
      Any other way of sorting that out

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Changed thread title to better describe the problem.

        Heya, kenno69.

        For info on how to send HTML emails, check out the manual page for mail(). Look towards the middle of the page.

        Comment

        • kenno69
          New Member
          • Jun 2007
          • 9

          #5
          Thanks, i really cannot see anything to do with changing the colour of the message, i must be blind or something cos i have really searched for it

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            Heya, kenno69.

            Originally posted by kenno69
            Thanks, i really cannot see anything to do with changing the colour of the message, i must be blind or something cos i have really searched for it
            To use HTML in an email message, you have to send special headers:

            Originally posted by PHP Manual
            [code=php]// To send HTML mail, the Content-type header must be set
            $headers = 'MIME-Version: 1.0' . "\r\n";
            $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
            .
            .
            .
            // Mail it
            mail($to, $subject, $message, $headers);
            [/code]


            This will make the email client evaluate HTML in your email, which will in turn make the text red.

            The only exception is if your email client doesn't support HTML emails, or if it has the HTML email option turned off.

            Comment

            • kenno69
              New Member
              • Jun 2007
              • 9

              #7
              Oh i didn't see that bit sorry. Thanks alot tho

              Comment

              • pbmods
                Recognized Expert Expert
                • Apr 2007
                • 5821

                #8
                Heya, kenno69.

                No problem. If you run into any further problems, just post 'em, and we'll help you out :)

                Comment

                Working...