SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Dec 2001
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Extract BODY from multi-part mime message

    I have a database full of email messages that I would like to display on a web page. Many messages though are "This is a multi-part message in MIME format". I would like to extract from these messages the useful part only, which is usually the part between the <body> tags. Is anyone aware of a function that could do this for me or otherwise a clever technique to achieve this? I am using php 4.3.9.

    Many thanks in advance for any tip.

  2. #2
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how are you parsing the emails ?
    PHP Code:
    <?
    preg_match
    ("|<body>(.*)<\/body>|Uis" $email_str $str );
    echo 
    $str[1];
    ?>
    would probably grab the body content if you have the email in $email_str , but you may be better served using IMAP or similar functions ?

  3. #3
    SitePoint Member
    Join Date
    Dec 2001
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your reply.

    Quote Originally Posted by firepages
    you may be better served using IMAP or similar functions ?
    I believe I cannot use IMAP functions like imap_fetchbody because I don't need to connect to a news server or a mail server (I don't have an imap_stream or msg_number). I have the email content in a database and they were stored there by another program.

    Any idea where I could find some php code to help me analyse and parse different type of email bodies (multi-part, html, text only..) ?

    Many thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •