• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 283
  • Last Modified:

Parse email message insert into mysql database using imap

Hi

I'm working on a script that retrives emails from the server using imap and inserts them in to database.

retrieving and inserting part works fine,
but when it comes to html messages the thing goes creazy

here is the result i get when i view the email from the database online. can someone help with cleaning this email up?

thanks

------------
This is a multi-part message in MIME format.brbr------_NextPart_000_0003_01C65CB9.A09AC300brContent-Type: text/plain;brcharsetus-asciibrContent-Transfer-Encoding: 7bitbrbrHere is the test emailbrbr brbr brbr brbr brbr brbrProfesionally YoursbrbrHarry Hovakbrbr-----------------------------brbrWebmaster Services PHP Mysql Developmentbrbrhttp://www.phpwork.combrbrWebmaster Tutorialsbrbrhttp://www.askwebexperts.combrbrInternet Turnkey Sitesbrbrhttp://www.internetturnkeysites.combrbr brbrbr------_NextPart_000_0003_01C65CB9.A09AC300brContent-Type: text/html;brcharsetus-asciibrContent-Transfer-Encoding: quoted-printablebrbrhtml xmlns:o3Durn:schemas-microsoft-com:office:office brxmlns:w3Durn:schemas-microsoft-com:office:word brxmlns3Dhttp://www.w3.org/TR/REC-html40brbrheadbrMETA HTTP-EQUIV3DContent-Type CONTENT3Dtext/html; brcharset3Dus-asciibrmeta name3DGenerator content3DMicrosoft Word 11 (filtered medium)brstylebr!--br /* Style Definitions */br p.MsoNormal, li.MsoNormal, div.MsoNormalbr{margin:0in;brmargin-bottom:.0001pt;brfont-size:12.0pt;brfont-family:Times New Roman;}bra:link, span.MsoHyperlinkbr{color:blue;brtext-decoration:underline;}bra:visited, span.MsoHyperlinkFollowedbr{color:purple;brtext-decoration:underline;}brspan.EmailStyle17br{mso-style-type:personal-compose;brfont-family:Arial;brcolor:windowtext;}br@page Section1br{size:8.5in 11.0in;brmargin:1.0in 1.25in 1.0in 1.25in;}brdiv.Section1br{page:Section1;}br--br/stylebrbr/headbrbrbody lang3DEN-US link3Dblue vlink3Dpurplebrbrdiv class3DSection1brbrp class3DMsoNormalfont size3D2 face3DArialspan brstyle3D'font-size:10.0pt;brfont-family:Arial'Here is the test emailo:p/o:p/span/font/pbrbrp class3DMsoNormalfont size3D2 face3DArialspan brstyle3D'font-size:10.0pt;brfont-family:Arial'o:pnbsp;/o:p/span/font/pbrbrp class3DMsoNormalfont size3D2 face3DArialspan brstyle3D'font-size:10.0pt;brfont-family:Arial'o:pnbsp;/o:p/span/font/pbrbrp class3DMsoNormalfont size3D3 face3DTimes New Romanspan brstyle3D'font-size:br12.0pt'nbsp;o:p/o:p/span/font/pbrbrp class3DMsoNormalfont size3D3 face3DTimes New Romanspan brstyle3D'font-size:br12.0pt'nbsp;o:p/o:p/span/font/pbrbrp class3DMsoNormalfont size3D3 face3DTimes New Romanspan brstyle3D'font-size:br12.0pt'nbsp;o:p/o:p/span/font/pbrbrp class3DMsoNormalfont size3D2 face3DArialspan brstyle3D'font-size:10.0pt;brfont-family:Arial'Profesionally Yours/span/fonto:p/o:p/pbrbrp class3DMsoNormalfont size3D2 face3DArialspan brstyle3D'font-size:10.0pt;brfont-family:Arial'Harry Hovak/span/fonto:p/o:p/pbrbrp class3DMsoNormalfont size3D2 face3DArialspan brstyle3D'font-size:10.0pt;brfont-family:Arial'-----------------------------/span/fonto:p/o:pbr/pbrbrp class3DMsoNormalstrongbfont size3D2 face3DArialspan brstyle3D'font-size:br10.0pt;font-family:Arial'Webmaster Services amp; PHP amp; Mysql brDevelopment/span/font/b/strongo:p/o:p/pbrbrp class3DMsoNormalfont size3D2 face3DArialspan brstyle3D'font-size:10.0pt;brfont-family:Arial'a brhref3Dhttp://www.phpwork.comhttp://www.phpwork.com/a/span/fontbro:p/o:p/pbrbrp class3DMsoNormalstrongbfont size3D2 face3DArialspan brstyle3D'font-size:br10.0pt;font-family:Arial'Webmaster brTutorials/span/font/b/strongo:p/o:p/pbrbrp class3DMsoNormalfont size3D2 face3DArialspan brstyle3D'font-size:10.0pt;brfont-family:Arial'a brhref3Dhttp://www.askwebexperts.comhttp://www.askwebexperts.com/a/sbrpan/fonto:p/o:p/pbrbrp class3DMsoNormalstrongbfont size3D2 face3DArialspan brstyle3D'font-size:br10.0pt;font-family:Arial'Internet Turnkey brSites/span/font/b/strongo:p/o:p/pbrbrp class3DMsoNormalfont size3D2 face3DArialspan brstyle3D'font-size:10.0pt;brfont-family:Arial'a brhref3Dhttp://www.internetturnkeysites.comhttp://www.internetturnkeysibrtes.com/a/span/fonto:p/o:p/pbrbrp class3DMsoNormalfont size3D3 face3DTimes New Romanspan brstyle3D'font-size:br12.0pt'o:pnbsp;/o:p/span/font/pbrbr/divbrbr/bodybrbr/htmlbrbr------_NextPart_000_0003_01C65CB9.A09AC300--brbr
-----------------------------------
0
cgibuys
Asked:
cgibuys
2 Solutions
 
blue_hunterCommented:
work out with Pear's package
Mail_Mime
to clean up your email

http://pear.php.net/package/Mail_Mime

*all the instructions on how you can applied this classes is listed in the tar file that you download from the link above.

all the best.
cheers
0
 
Eddie ShipmanAll-around developerCommented:
Use this:
htmlspecialchars(quoted_printable_decode(imap_body($mailbox,$index)));

BTW, that is some attrocious looking MSWord HTML.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now