send PHP mail with Content-Type: multipart/alternative

后端 未结 4 1413
抹茶落季
抹茶落季 2020-12-11 19:37

I am trying to send a multipart mail that contains both html and plain text. This is also one of the ways to get through spam filters and to allow more people to read the ma

4条回答
  •  感情败类
    2020-12-11 19:42

    Here is the complete script without errors:

    \n";
    $header .= "Reply-To: ".$mailto."\n";
    $header .= "MIME-Version: 1.0"."\n";
    $header .= "Content-type: multipart/alternative; boundary=\"----=_NextPart_" . $boundary . "\"";
    
    $message = "This is multipart message using MIME\n";
    
    $message .= "------=_NextPart_" . $boundary . "\n";
    $message .= "Content-Type: text/plain; charset=UTF-8\n";
    $message .= "Content-Transfer-Encoding: 7bit". "\n\n";
    $message .= "Plain text version\n\n";
    $message .="------=_NextPart_" . $boundary . "\n";
    $message .="Content-Type: text/html; charset=UTF-8\n";
    $message .= "Content-Transfer-Encoding: 7bit". "\n\n";
    
    $message .="
    
    
    HTML text version
    \n\n"; $message .= "------=_NextPart_" . $boundary . "--"; if(@mail($mailto, $subject, $message, $header)) { print'message sent'; } else { print"message was not sent"; } ?>

提交回复
热议问题