Parse email message insert into mysql  database using imap

Posted on 2006-04-10
Last Modified: 2006-11-18

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?


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 brxmlns3D 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.com 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.com 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.com 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
Question by:cgibuys
    LVL 9

    Accepted Solution

    work out with Pear's package
    to clean up your email

    *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.
    LVL 26

    Assisted Solution

    Use this:

    BTW, that is some attrocious looking MSWord HTML.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now