Pergunta

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?

Foi útil?

Solução

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.

Outras dicas

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

If this match, then it is HTML.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top