Results 1 to 4 of 4

Thread: Preserve special html char?

  1. #1

    Thread Starter
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Preserve special html char?

    I am setting up a phpbb board and may need to email people things from time to time, well just tested out the mail() function to my yahoo beta account and if i try and send a link such as,

    PHP Code:
    <?php
    $content 
    ="<a href ='http://www.mylink.com'>Click me</a>";
    mail($to,$subject,$content);

    //etc..
    ?>
    Then it not rendered right in yahoo the <'s become &lt; etc, i have tried using,

    PHP Code:
    $content htmlspecialchars("<a href ='http://www.mylink'>click me</a>"ENT_QUOTES); 
    but no difference...

    any ideas?

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Preserve special html char?

    I don't recommend sending HTML emails, but to do so, you need to set the content type to text/html; otherwise, the receiving client will treat them as plain text, which is what's happening here.

    PHP Code:
    mail($to$subject$content"Content-type: text/html; charset=utf-8\r\n"); 
    Some examples.

  3. #3

    Thread Starter
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Preserve special html char?

    excellent as always, why against html email's?

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Preserve special html char?

    Here's a list of reasons: Why HTML in E-Mail is a Bad Idea.
    The author may have largely changed his opinion since, but I agree with most, although not all, of the points on that page.

Posting Permissions

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



Click Here to Expand Forum to Full Width