Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: HTML email???

  1. #1
    New Coder fireblade's Avatar
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    HTML email???

    in PHP normal mail function
    PHP Code:
    mail($to$subject$body
    can I use HTML body which contains
    Code:
    <a href="link">some text </a>
    codes like.......

    will the mail be sent as HTML??

    if not what should i do to send HTML mail??? any body can help me??
    Fi®e bLádê
    follow me on twitter

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    The mail() function accepts 4 items. The to email address, the subject, the message, and the headers. If you don't specify the headers the default is text/plain. Put this before you call the mail() function
    Code:
    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "From: you@domain.com\r\n" .
                "Reply-To: ".$to."";
    Then you call the mail() function like so
    Code:
    mail($to, $subject, $body,$headers)
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Regular Coder meth's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Thanks
    0
    Thanked 9 Times in 9 Posts
    Another tip for html email, use heredoc syntax to build the html of the message. Heredoc behaves like double quotes without having to actually use them. Very handy for html tags with lots of attributes...
    I do Web Design, Brisbane based.
    More time spent in PHP/MySQL Web Development.
    And Search Engine Optimisation takes up the rest of it.


  •  

    Posting Permissions

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