#1
  1. No Profile Picture
    Robert_J_Sherman
    Guest
    Devshed Newbie (0 - 499 posts)
    The function imap_headers() returns the
    headers of a given mail message residing on the server.

    What I'm looking for is a quick example of taking that information, and spliting it up.

    for example, in the return of:
    $headers = imap_headers($blahblah);
    echo $headers[0];

    this would return the status, uid, from, subject, size.

    I'm curious if this is an array?

    or is it a single line return.

    If it's not an array, can someone suggest the function I would need to use to pull out the information in the form of an array?

    ------------------
    SnR Graphics,
    Low Cost Hosting and Web Development.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Denmark
    Posts
    4
    Rep Power
    0
    It is an array with lists over the parts you mentioned.

    for($idx=0; $idx < $num_elements; ++$idx)
    {echo("$headers[$idx] <br>n");}
    This will return a list over the array elements.
    But not arranged by items/elements.

    I have the same problem, so I hope to see, if You can get at sollution

    ------------------
    Gitte Tved
    Super24 ApS
    Denmark
  4. #3
  5. No Profile Picture
    Robert_J_Sherman
    Guest
    Devshed Newbie (0 - 499 posts)
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by digit:
    It is an array with lists over the parts you mentioned.

    for($idx=0; $idx < $num_elements; ++$idx)
    {echo("$headers[$idx] <br>n");}
    This will return a list over the array elements.
    But not arranged by items/elements.

    I have the same problem, so I hope to see, if You can get at sollution
    [/quote]

    I know this is a bit huge, but here's what I managed to decipher from the manual, which for me has returned a nicely formatted message header.. the problem for me is body decoding, and that I know really requires the imap_fetch_structure() function.. otherwise I can get the body, but when it has attachments, it's not a pretty site.

    Anyway, here's an "else" segement from my mail client, that decodes and formats the message header:

    else {
    $header = imap_header($mbox, $msgnum);
    echo "Date: ".$header->Date."<br>n";
    if ($header->reply_to) {
    echo "Reply-To: ";
    $personal = $header->reply_to[0]->personal;
    $ReplytoEMAIL = "<".$header->reply_to[0]->mailbox."@".$header->reply_to[0]->host.">";
    if ($personal) { echo "&quot;".$personal."&quot;"; }
    if ($ReplytoEMAIL) { echo " ".$ReplytoEMAIL; }
    echo "<br>n";
    }

    echo "From: ";
    $personal = $header->from[0]->personal;
    $fromEMAIL = "<".$header->from[0]->mailbox."@".$header->from[0]->host.">";
    if ($personal) { echo "&quot;".$personal."&quot;"; }
    if ($fromEMAIL) { echo " ".$fromEMAIL; }
    echo "<br>n";

    echo "To: ";
    $personal = $header->to[0]->personal;
    $toEMAIL = "<".$header->to[0]->mailbox."@".$header->to[0]->host.">";
    if ($personal) { echo "&quot;".$personal."&quot;"; }
    if ($toEMAIL) { echo " ".$toEMAIL; }
    echo "<br>n";

    if ($header->cc) {
    echo "Cc: ";
    $personal = $header->cc[0]->personal;
    $CcEMAIL = "<".$header->cc[0]->mailbox."@".$header->cc[0]->host.">";
    if ($personal) { echo "&quot;".$personal."&quot;"; }
    if ($CcEMAIL) { echo " ".$CcEMAIL; }
    echo "<br>n";
    }

    echo "Subject: ".$header->Subject."<br>n";
    $subject = urlencode($header->Subject);
    echo "<br><br>n<a href="$PHP_SELF?msgnum=$msgnum&fullheader=true&subject=$subject" class="poplink">View Full Header</a>n";
    echo "<hr width="493" noshade size="1">n<br>n<br>n";
    }

    The initial "if" statement displays and formats the "full" header..

    ------------------
    SnR Graphics,
    Low Cost Hosting and Web Development.

Similar Threads

  1. Replies: 2
    Last Post: August 18th, 2004, 10:45 PM
  2. Replies: 4
    Last Post: January 28th, 2004, 08:29 AM
  3. PHP with UnixODBC
    By coder4hire in forum PHP Development
    Replies: 2
    Last Post: January 20th, 2004, 01:14 PM
  4. Passing string from PHP to Javascript
    By ka8oad in forum JavaScript Development
    Replies: 4
    Last Post: January 17th, 2004, 03:12 PM
  5. UnixODBC + PHP + Apache + Empress
    By coder4hire in forum Database Management
    Replies: 0
    Last Post: January 15th, 2004, 01:41 PM

IMN logo majestic logo threadwatch logo seochat tools logo