How to send an HTML email using SMTP in PHP

后端 未结 6 1645
醉梦人生
醉梦人生 2021-01-14 19:56

I\'ve been able to send an email using SMTP in PHP, but when I try to change the Content Type to HTML, the email doesn\'t get delivered. This is the code I\'m trying to use:

6条回答
  •  [愿得一人]
    2021-01-14 20:38

    You should create the mail body via mime object. And pear will handle it from there. Ex:

         $crlf = "\n";
        // Creating the Mime message
        $mime = new Mail_mime($crlf);
    
        // Setting the body of the email
        $mime->setTXTBody($text);
        $mime->setHTMLBody($html);
       ...
        $body = $mime->get();
    

提交回复
热议问题