Pregunta

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?

¿Fue útil?

Solución

Yes, you can use strip_tags() and compare filtered mail-body with original one to see are there any differences but don't forget, in plain-text you may have HTML tags as normal text and I think that strip_tags() will remove these tags too.

Otros consejos

preg_match('/\<html\>(.*)\<\/html\>/', $emailbody)

If this match, then it is HTML.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top