Include html in email

后端 未结 4 1339
遇见更好的自我
遇见更好的自我 2020-12-22 12:02

I need to include some HTML things in PHP, for example to add link in a message like this:



        
4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-22 12:40

    This is very basic: mail()

    Set the correct headers (from php.net)

    // 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);
    

    your $message may now contain HTML. For complex html/emails, it's advisable to look at some packages such as the PEAR Mailer class for instance.

提交回复
热议问题