[SOLVED] Detect if an .EML file is plain text or HTML
Posted: Thu Mar 29, 2007 7:29 am
I'm using a Thunderbird plugin to send selected e-mail to PHP to insert into a MySQL database and then I've created a mail centre to view uploaded e-mails. At first I was having problems reading plain text e-mails because new lines weren't being created so I used the following line of code:
Which places "<br>" where "\r", "\n" or "\r\n" are in a plain text e-mail. Now my problem
The htmlentities was to show any "<" or ">" that may have been user created in an e-mail.
Now my problem is that HTML e-mails are showing all the HTML tags, which isn't what I want. I think the solution is to handle the data differently depending on whether the HTML is plain text or whether it is HTML. How would PHP determine if an e-mail was a HTML e-mail or plain text?
Regards,
Code: Select all
$bodyToDatabase = nl2br(htmlentities($bodyToDatabase));The htmlentities was to show any "<" or ">" that may have been user created in an e-mail.
Now my problem is that HTML e-mails are showing all the HTML tags, which isn't what I want. I think the solution is to handle the data differently depending on whether the HTML is plain text or whether it is HTML. How would PHP determine if an e-mail was a HTML e-mail or plain text?
Regards,