PHP - Plain text email

只愿长相守 提交于 2019-12-06 11:35:56

问题


How to turn this into a plain text email?

 $bound_text=md5(uniqid(time()));
    $headers.="MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed; boundary=\"PHP-mixed-$bound_text\"\r\n";

    $message="--PHP-mixed-$bound_text\r\n"      
                ."Content-Type: text/html; charset=\"utf-8\"\r\n"
                ."Content-Transfer-Encoding: 7bit\r\n\r\n"  
                ."<html><head></head><body>"
                ."<div style=\"font-family: Arial, Helvetica, sans-serif; font-size : 1.3em; color: #000000;width: 100%;text-align: left;\">$text_message</div></body></html>\r\n\r\n"  
                ."--PHP-mixed-$bound_text\r\n"  
                ."Content-Transfer-Encoding: base64\r\n"
                ."Content-Disposition: attachment; filename=\"$attachment\"\r\n"
    ."Content-Type: image/jpeg; name=\"$attachment\"\r\n\r\n"
     .chunk_split($file)
            ."\r\n\r\n"
                ."--PHP-mixed-$bound_text--\r\n\r\n";

    }

Is it just removing the HTML part and changing text/html into text/plain?


回答1:


Removing the HTML should do the trick but you'll probably want to change the content-type to text/plain as well:

."Content-Type: text/plain; charset=\"utf-8\"\r\n"

(I would have let a comment suffice but I can't post comments yet :))



来源:https://stackoverflow.com/questions/9095152/php-plain-text-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!