In my application I am processing mail texts using PHP. For some mail clients such as sina.com is sending bad headers. For example, they are sending HTML mail but sending the header Content-Type as text/plain.
Now, for these mails, my application is considering the HTML as text. In PHP how can I detect if a text contain html text or not?
是的,您可以使用strip_tags()
并将经过过滤的邮件正文与原始邮件进行比较,以查看是否存在差异,但是请不要忘记,在纯文本中,您可能会将HTML标签作为普通文本,并且我认为strip_tags()
将删除这些标签。
preg_match('/\<html\>(.*)\<\/html\>/', $emailbody)
如果匹配,则为HTML。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.